Skip to content

Commit 05b2d2b

Browse files
committed
🐛 Fix delete file with auto export config
When calling `DatabaseStorage.delete`, there is a process that deletes the cache if it exists on the file system, and in the `get_hash_fn` function called in that process, if the destination directory for the cache file does not exist on the file system, it creates it. If there is no directory on the file system to store the cache file, the process creates it.
1 parent d4f9b5b commit 05b2d2b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

binary_database_files/storage.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,10 @@ def delete(self, name):
142142
name = self.get_instance_name(name)
143143
try:
144144
models.File.objects.get_from_name(name).delete()
145-
hash_fn = utils.get_hash_fn(name)
146-
if os.path.isfile(hash_fn):
147-
os.remove(hash_fn)
145+
if _settings.DB_FILES_AUTO_EXPORT_DB_TO_FS:
146+
hash_fn = utils.get_hash_fn(name)
147+
if os.path.isfile(hash_fn):
148+
os.remove(hash_fn)
148149
except models.File.DoesNotExist:
149150
pass
150151
localpath = self._path(name)

0 commit comments

Comments
 (0)