Patch .filepart uploads not being handled.

This commit is contained in:
zaCade 2026-01-02 15:41:31 +01:00
parent 1237ae8f28
commit 3dcd527b71

View File

@ -236,24 +236,40 @@ class EventHandler(pyinotify.ProcessEvent):
def my_init(self, source, destination):
self.SourceDirectory = os.path.abspath(source)
self.DestinationDirectory = os.path.abspath(destination)
self.FilepartList = []
def process_IN_CLOSE_WRITE(self, event):
if not event.pathname.endswith(valid_extensions) or os.path.basename(event.pathname) in ignore_names or any(folder in event.pathname for folder in ignore_folders):
return
destpath = os.path.join(self.DestinationDirectory, os.path.relpath(event.pathname, os.path.join(self.SourceDirectory, "..")))
jobs.put((Compress, event.pathname, destpath + ".bz2"))
def process_IN_DELETE(self, event):
destpath = os.path.join(self.DestinationDirectory, os.path.relpath(event.pathname, os.path.join(self.SourceDirectory, "..")))
if event.dir:
if os.path.exists(destpath):
jobs.put((Delete, destpath))
if event.pathname.endswith(".filepart"):
self.FilepartList.append(event.pathname[:-9]) # Append the file (without .filepart) to the filepart list, so we can track it for the IN_CREATE event
else:
if not event.pathname.endswith(valid_extensions) or os.path.basename(event.pathname) in ignore_names or any(folder in event.pathname for folder in ignore_folders):
return
jobs.put((Delete, destpath + ".bz2"))
destpath = os.path.join(self.DestinationDirectory, os.path.relpath(event.pathname, os.path.join(self.SourceDirectory, "..")))
jobs.put((Compress, event.pathname, destpath + ".bz2"))
def process_IN_CREATE(self, event):
# Only handle files in the filepart list, other files might not be finished and are handled above
if event.pathname in self.FilepartList:
if not event.pathname.endswith(valid_extensions) or os.path.basename(event.pathname) in ignore_names or any(folder in event.pathname for folder in ignore_folders):
return
destpath = os.path.join(self.DestinationDirectory, os.path.relpath(event.pathname, os.path.join(self.SourceDirectory, "..")))
jobs.put((Compress, event.pathname, destpath + ".bz2"))
def process_IN_DELETE(self, event):
if event.pathname.endswith(".filepart"):
self.FilepartList.remove(event.pathname[:-9]) # Remove the file (without .filepart) from the filepart list, we are done tracking it
else:
destpath = os.path.join(self.DestinationDirectory, os.path.relpath(event.pathname, os.path.join(self.SourceDirectory, "..")))
if event.dir:
if os.path.exists(destpath):
jobs.put((Delete, destpath))
else:
if not event.pathname.endswith(valid_extensions) or os.path.basename(event.pathname) in ignore_names or any(folder in event.pathname for folder in ignore_folders):
return
jobs.put((Delete, destpath + ".bz2"))
def process_IN_MOVED_TO(self, event):
# Moved from untracked directory, handle as new file