mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-05 20:01:54 +02:00
Ensure cache_cleaning only targets remote files
This commit is contained in:
parent
6572db3a83
commit
428de17817
2 changed files with 13 additions and 3 deletions
|
@ -29,7 +29,8 @@ def clean_music_cache():
|
|||
candidates = (
|
||||
music_models.Upload.objects.filter(
|
||||
Q(audio_file__isnull=False)
|
||||
& (Q(accessed_date__lt=limit) | Q(accessed_date=None))
|
||||
& (Q(accessed_date__lt=limit) | Q(accessed_date=None)),
|
||||
# library__actor__user=None,
|
||||
)
|
||||
.local(False)
|
||||
.exclude(audio_file="")
|
||||
|
@ -55,8 +56,10 @@ def get_files(storage, *parts):
|
|||
"""
|
||||
if not parts:
|
||||
raise ValueError("Missing path")
|
||||
|
||||
dirs, files = storage.listdir(os.path.join(*parts))
|
||||
try:
|
||||
dirs, files = storage.listdir(os.path.join(*parts))
|
||||
except FileNotFoundError:
|
||||
return []
|
||||
for dir in dirs:
|
||||
files += get_files(storage, *(list(parts) + [dir]))
|
||||
return [os.path.join(parts[-1], path) for path in files]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue