cleanup staging folder same as download folder
This commit is contained in:
parent
07a79e7af6
commit
d1890c768c
2 changed files with 23 additions and 15 deletions
|
|
@ -1109,25 +1109,33 @@ def _register_automation_handlers():
|
||||||
_update_automation_progress(automation_id,
|
_update_automation_progress(automation_id,
|
||||||
log_line=f'Empty directories: removed {dirs_removed}', log_type='success' if dirs_removed else 'info')
|
log_line=f'Empty directories: removed {dirs_removed}', log_type='success' if dirs_removed else 'info')
|
||||||
|
|
||||||
# --- 4. Clear staging folder ---
|
# --- 4. Sweep empty staging directories ---
|
||||||
_update_automation_progress(automation_id, phase='Clearing staging folder...', progress=60)
|
_update_automation_progress(automation_id, phase='Sweeping staging folder...', progress=60)
|
||||||
staging_path = _get_staging_path()
|
staging_path = _get_staging_path()
|
||||||
s_removed = 0
|
s_removed = 0
|
||||||
if os.path.isdir(staging_path):
|
if os.path.isdir(staging_path):
|
||||||
for f in os.listdir(staging_path):
|
for dirpath, _dirnames, _filenames in os.walk(staging_path, topdown=False):
|
||||||
fp = os.path.join(staging_path, f)
|
if os.path.normpath(dirpath) == os.path.normpath(staging_path):
|
||||||
|
continue
|
||||||
try:
|
try:
|
||||||
if os.path.isfile(fp):
|
entries = os.listdir(dirpath)
|
||||||
os.remove(fp)
|
except OSError:
|
||||||
|
continue
|
||||||
|
visible = [e for e in entries if not e.startswith('.')]
|
||||||
|
if not visible:
|
||||||
|
for hidden in entries:
|
||||||
|
try:
|
||||||
|
os.remove(os.path.join(dirpath, hidden))
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
os.rmdir(dirpath)
|
||||||
s_removed += 1
|
s_removed += 1
|
||||||
elif os.path.isdir(fp):
|
except OSError:
|
||||||
_shutil.rmtree(fp)
|
pass
|
||||||
s_removed += 1
|
steps.append(f'Staging: removed {s_removed} empty directories')
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
steps.append(f'Staging: removed {s_removed} items')
|
|
||||||
_update_automation_progress(automation_id,
|
_update_automation_progress(automation_id,
|
||||||
log_line=f'Staging: removed {s_removed} items', log_type='success' if s_removed else 'info')
|
log_line=f'Staging: removed {s_removed} empty directories', log_type='success' if s_removed else 'info')
|
||||||
|
|
||||||
# --- 5. Clean search history ---
|
# --- 5. Clean search history ---
|
||||||
_update_automation_progress(automation_id, phase='Cleaning search history...', progress=80)
|
_update_automation_progress(automation_id, phase='Cleaning search history...', progress=80)
|
||||||
|
|
|
||||||
|
|
@ -17583,7 +17583,7 @@ const TOOL_HELP_CONTENT = {
|
||||||
<li><strong>Clear Quarantine</strong> — permanently deletes all quarantined files</li>
|
<li><strong>Clear Quarantine</strong> — permanently deletes all quarantined files</li>
|
||||||
<li><strong>Clear Download Queue</strong> — removes completed, errored, and cancelled downloads from Soulseek</li>
|
<li><strong>Clear Download Queue</strong> — removes completed, errored, and cancelled downloads from Soulseek</li>
|
||||||
<li><strong>Sweep Empty Directories</strong> — removes empty folders left behind in the downloads directory</li>
|
<li><strong>Sweep Empty Directories</strong> — removes empty folders left behind in the downloads directory</li>
|
||||||
<li><strong>Clear Staging Folder</strong> — deletes all files and folders from the import staging area</li>
|
<li><strong>Sweep Staging Folder</strong> — removes empty directories from the import staging area</li>
|
||||||
<li><strong>Clean Search History</strong> — trims old Soulseek search queries</li>
|
<li><strong>Clean Search History</strong> — trims old Soulseek search queries</li>
|
||||||
</ol>
|
</ol>
|
||||||
|
|
||||||
|
|
@ -47483,7 +47483,7 @@ const _RESULT_DISPLAY_MAP = {
|
||||||
],
|
],
|
||||||
'full_cleanup': [
|
'full_cleanup': [
|
||||||
{ key: 'quarantine_removed', label: 'Quarantine Removed' },
|
{ key: 'quarantine_removed', label: 'Quarantine Removed' },
|
||||||
{ key: 'staging_removed', label: 'Staging Removed' },
|
{ key: 'staging_removed', label: 'Staging Dirs Removed' },
|
||||||
{ key: 'total_removed', label: 'Total Items Removed' },
|
{ key: 'total_removed', label: 'Total Items Removed' },
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue