Introduce DELETE_FILE_ON_TRASHCAN option, to delete files on the server

This commit is contained in:
guahki
2023-04-16 13:07:25 +02:00
parent 462a840a56
commit 8283716547
3 changed files with 6 additions and 1 deletions

View File

@@ -19,6 +19,7 @@ class Config:
'AUDIO_DOWNLOAD_DIR': '%%DOWNLOAD_DIR',
'CUSTOM_DIRS': 'true',
'CREATE_CUSTOM_DIRS': 'true',
'DELETE_FILE_ON_TRASHCAN': 'false',
'STATE_DIR': '.',
'URL_PREFIX': '',
'OUTPUT_TEMPLATE': '%(title)s.%(ext)s',
@@ -29,7 +30,7 @@ class Config:
'BASE_DIR': ''
}
_BOOLEAN = ('CUSTOM_DIRS', 'CREATE_CUSTOM_DIRS')
_BOOLEAN = ('CUSTOM_DIRS', 'CREATE_CUSTOM_DIRS', 'DELETE_FILE_ON_TRASHCAN')
def __init__(self):
for k, v in self._DEFAULTS.items():

View File

@@ -292,6 +292,9 @@ class DownloadQueue:
if not self.done.exists(id):
log.warn(f'requested delete for non-existent download {id}')
continue
if self.config.DELETE_FILE_ON_TRASHCAN:
dl = self.done.get(id)
os.remove(os.path.join(dl.download_dir, dl.info.filename))
self.done.delete(id)
await self.notifier.cleared(id)
return {'status': 'ok'}