35 lines
899 B
Python
35 lines
899 B
Python
import logging
|
|
import os
|
|
from components.ErrorDialog import ErrorDialog
|
|
|
|
|
|
def batch_delete_filepaths_from_filesystem(
|
|
files: list[str], progress_callback=None
|
|
) -> bool:
|
|
"""
|
|
Handles deleting song files from filesystem
|
|
|
|
Args:
|
|
- files: a list of absolute filepaths to songs
|
|
- progress_callback: emit this signal for user feedback
|
|
|
|
Returns True on success
|
|
False on failure/error
|
|
"""
|
|
# Get song IDs from filepaths
|
|
try:
|
|
for file in files:
|
|
os.remove(file)
|
|
if progress_callback:
|
|
progress_callback.emit(f'Removing {file}')
|
|
except Exception as e:
|
|
logging.error(
|
|
f"An error occurred during batch processing: {e}"
|
|
)
|
|
dialog = ErrorDialog(
|
|
f"An error occurred during batch processing: {e}"
|
|
)
|
|
dialog.exec_()
|
|
return False
|
|
return True
|