fix filesystem rescan without task

This commit is contained in:
simon 2023-05-07 15:36:26 +07:00
parent 5e1167743f
commit 774780d520
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
1 changed files with 8 additions and 4 deletions

View File

@ -127,7 +127,8 @@ class Filesystem(ScannerBase):
def process(self): def process(self):
"""entry point""" """entry point"""
self.task.send_progress(["Scanning your archive and index."]) if self.task:
self.task.send_progress(["Scanning your archive and index."])
self.scan() self.scan()
self.rename_files() self.rename_files()
self.send_mismatch_bulk() self.send_mismatch_bulk()
@ -140,7 +141,8 @@ class Filesystem(ScannerBase):
return return
total = len(self.to_rename) total = len(self.to_rename)
self.task.send_progress([f"Rename {total} media files."]) if self.task:
self.task.send_progress([f"Rename {total} media files."])
for bad_filename in self.to_rename: for bad_filename in self.to_rename:
channel, filename, expected_filename = bad_filename channel, filename, expected_filename = bad_filename
print(f"renaming [{filename}] to [{expected_filename}]") print(f"renaming [{filename}] to [{expected_filename}]")
@ -154,7 +156,8 @@ class Filesystem(ScannerBase):
return return
total = len(self.mismatch) total = len(self.mismatch)
self.task.send_progress([f"Fix media urls for {total} files"]) if self.task:
self.task.send_progress([f"Fix media urls for {total} files"])
bulk_list = [] bulk_list = []
for video_mismatch in self.mismatch: for video_mismatch in self.mismatch:
youtube_id, media_url = video_mismatch youtube_id, media_url = video_mismatch
@ -174,7 +177,8 @@ class Filesystem(ScannerBase):
return return
total = len(self.to_delete) total = len(self.to_delete)
self.task.send_progress([f"Clean up {total} items from index."]) if self.task:
self.task.send_progress([f"Clean up {total} items from index."])
for indexed in self.to_delete: for indexed in self.to_delete:
youtube_id = indexed[0] youtube_id = indexed[0]
print(f"deleting {youtube_id} from index") print(f"deleting {youtube_id} from index")