mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 13:59:15 +02:00
Delete existing thumbnails automatically when running
This commit is contained in:
parent
f400d2568b
commit
53b5c6261e
2 changed files with 24 additions and 1 deletions
|
@ -1,3 +1,5 @@
|
|||
import os
|
||||
import shutil
|
||||
import slugify
|
||||
|
||||
from django.core.files.storage import FileSystemStorage
|
||||
|
@ -15,6 +17,16 @@ class ASCIIFileSystemStorage(FileSystemStorage):
|
|||
def get_valid_name(self, name):
|
||||
return super().get_valid_name(asciionly(name))
|
||||
|
||||
def force_delete(self, name):
|
||||
path = self.path(name)
|
||||
try:
|
||||
if os.path.isdir(path):
|
||||
shutil.rmtree(path)
|
||||
else:
|
||||
return super().delete(name)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
|
||||
class ASCIIS3Boto3Storage(S3Boto3Storage):
|
||||
def get_valid_name(self, name):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue