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()
|
||||||
|
|
||||||
if instance.version.files.count() == 0:
|
# this code is already quite convoluted
|
||||||
# this was the last file, clean up the version
|
# TODO? maybe find some way to have a predictable order of deletion
|
||||||
logger.info('Deleting Version pk=%s because its last file was deleted', instance.version.pk)
|
try:
|
||||||
instance.version.delete()
|
if instance.version.files.count() == 0:
|
||||||
|
# this was the last file, clean up the version
|
||||||
|
logger.info(
|
||||||
|
'Deleting Version pk=%s because its last file was deleted',
|
||||||
|
instance.version.pk,
|
||||||
|
)
|
||||||
|
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