mirror of
https://github.com/tcsenpai/swingmusic.git
synced 2025-06-06 03:05:35 +00:00
handle the FileNotFoundError for os.path.getsize on watchdogg
This commit is contained in:
parent
e70d787580
commit
18f6593666
@ -53,7 +53,7 @@ class ProcessAlbumColors:
|
||||
"""
|
||||
|
||||
def __init__(self) -> None:
|
||||
albums = [a for a in AlbumStore.albums if a is None or len(a.colors) == 0]
|
||||
albums = [a for a in AlbumStore.albums if a is not None and len(a.colors) == 0]
|
||||
|
||||
with SQLiteManager() as cur:
|
||||
try:
|
||||
|
@ -246,9 +246,13 @@ class Handler(PatternMatchingEventHandler):
|
||||
"""
|
||||
Fired when a supported file is created.
|
||||
"""
|
||||
try:
|
||||
self.file_sizes[event.src_path] = os.path.getsize(event.src_path)
|
||||
except FileNotFoundError:
|
||||
return
|
||||
|
||||
self.files_to_process.append(event.src_path)
|
||||
self.files_to_process_windows.append(event.src_path)
|
||||
self.file_sizes[event.src_path] = os.path.getsize(event.src_path)
|
||||
|
||||
def on_deleted(self, event):
|
||||
"""
|
||||
@ -304,7 +308,12 @@ class Handler(PatternMatchingEventHandler):
|
||||
return
|
||||
|
||||
# Check if file write operation is complete
|
||||
current_size = os.path.getsize(event.src_path)
|
||||
try:
|
||||
current_size = os.path.getsize(event.src_path)
|
||||
except FileNotFoundError:
|
||||
# File was deleted or moved
|
||||
return
|
||||
|
||||
previous_size = self.file_sizes.get(event.src_path, -1)
|
||||
|
||||
if current_size == previous_size:
|
||||
@ -315,7 +324,7 @@ class Handler(PatternMatchingEventHandler):
|
||||
try:
|
||||
current_size = os.path.getsize(event.src_path)
|
||||
except FileNotFoundError:
|
||||
# File was deleted
|
||||
# File was deleted or moved
|
||||
return
|
||||
|
||||
if current_size == previous_size:
|
||||
|
Loading…
x
Reference in New Issue
Block a user