Multi-platform: support multiple files per version #201
@ -43,10 +43,18 @@ def _delete_versionfiles_file(
|
|||||||
logger.info('Deleting File pk=%s of VersionFile pk=%s', file.pk, instance.pk)
|
logger.info('Deleting File pk=%s of VersionFile pk=%s', file.pk, instance.pk)
|
||||||
file.delete()
|
file.delete()
|
||||||
|
|
||||||
|
# this code is already quite convoluted
|
||||||
|
# TODO? maybe find some way to have a predictable order of deletion
|
||||||
|
try:
|
||||||
if instance.version.files.count() == 0:
|
if instance.version.files.count() == 0:
|
||||||
# this was the last file, clean up the version
|
# this was the last file, clean up the version
|
||||||
logger.info('Deleting Version pk=%s because its last file was deleted', instance.version.pk)
|
logger.info(
|
||||||
|
'Deleting Version pk=%s because its last file was deleted',
|
||||||
|
instance.version.pk,
|
||||||
|
)
|
||||||
instance.version.delete()
|
instance.version.delete()
|
||||||
|
except extensions.models.Version.DoesNotExist:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
@receiver(pre_save, sender=extensions.models.Extension)
|
@receiver(pre_save, sender=extensions.models.Extension)
|
||||||
|
Loading…
Reference in New Issue
Block a user