Prevent re-addition of finished files to queue

This commit is contained in:
Kumi 2021-12-03 09:08:51 +01:00
parent fc56013305
commit b736226140
2 changed files with 22 additions and 3 deletions

View file

@ -130,14 +130,31 @@ class ShoreThread(Process):
else:
outlist.append(f)
self._logger.debug(f"File {fileobj.name} not in processing queue (anymore) - adding")
outlist.append(fileobj)
if self.checkFileCompletion(fileobj):
self._logger.debug(f"File {fileobj.name} already transferred to all Vessels - not re-adding to queue")
else:
self._logger.debug(f"File {fileobj.name} not in processing queue (anymore) - adding")
outlist.append(fileobj)
self.clearFiles()
for f in outlist:
self._state["files"].append(f)
def checkFileCompletion(self, fileobj: File) -> bool:
db = Database()
complete = db.getCompletionByFileUUID(fileobj.uuid)
del(db)
for vessel in self._state["config"].vessels:
if vessel.name not in complete and fileobj.directory.name not in vessel._ignoredirs:
return False
if fileobj.exists():
fileobj.moveCompleted()
return True
def processFile(self, directory: Directory, name: str) -> None:
"""Process a file entry from the observer queue

View file

@ -153,7 +153,9 @@ class VesselThread(Process):
self._logger.debug(
f"File {fileobj.name} from Directory {fileobj.directory.name} transferred to all Vessels. Moving out of replication directory.")
fileobj.moveCompleted()
if fileobj.exists():
fileobj.moveCompleted()
def processQueue(self) -> Optional[str]:
"""Return a file from the processing queue