Skip to content

Commit e87e698

Browse files
committed
Fix remove export files if export has failed
If export task is failed there is no file and therefore instance.filename is None and makes an error
1 parent 50558c0 commit e87e698

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

lib/booktype/apps/export/models.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ def has_subdir(dirpath):
7272

7373
@receiver(post_delete, sender=ExportFile)
7474
def _exportfile_delete(sender, instance, **kwargs):
75-
relative_export_file = instance.filename.lstrip('/')
76-
export_file = os.path.join(settings.BOOKTYPE_ROOT, relative_export_file)
77-
export_type_dir = os.path.dirname(export_file)
78-
export_main_dir = os.path.dirname(export_type_dir)
7975
try:
76+
relative_export_file = instance.filename.lstrip('/')
77+
export_file = os.path.join(settings.BOOKTYPE_ROOT, relative_export_file)
78+
export_type_dir = os.path.dirname(export_file)
79+
export_main_dir = os.path.dirname(export_type_dir)
8080
shutil.rmtree(export_type_dir)
8181
if not has_subdir(export_main_dir):
8282
shutil.rmtree(export_main_dir)

0 commit comments

Comments
 (0)