mirror of
https://github.com/tcsenpai/swingmusic.git
synced 2025-06-09 12:37:22 +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:
|
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:
|
with SQLiteManager() as cur:
|
||||||
try:
|
try:
|
||||||
|
@ -246,9 +246,13 @@ class Handler(PatternMatchingEventHandler):
|
|||||||
"""
|
"""
|
||||||
Fired when a supported file is created.
|
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.append(event.src_path)
|
||||||
self.files_to_process_windows.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):
|
def on_deleted(self, event):
|
||||||
"""
|
"""
|
||||||
@ -304,7 +308,12 @@ class Handler(PatternMatchingEventHandler):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Check if file write operation is complete
|
# Check if file write operation is complete
|
||||||
|
try:
|
||||||
current_size = os.path.getsize(event.src_path)
|
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)
|
previous_size = self.file_sizes.get(event.src_path, -1)
|
||||||
|
|
||||||
if current_size == previous_size:
|
if current_size == previous_size:
|
||||||
@ -315,7 +324,7 @@ class Handler(PatternMatchingEventHandler):
|
|||||||
try:
|
try:
|
||||||
current_size = os.path.getsize(event.src_path)
|
current_size = os.path.getsize(event.src_path)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
# File was deleted
|
# File was deleted or moved
|
||||||
return
|
return
|
||||||
|
|
||||||
if current_size == previous_size:
|
if current_size == previous_size:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user