mirror of
https://github.com/meeb/tubesync.git
synced 2025-06-23 13:36:35 +00:00
Coordination with deletion of Source
instances
This commit is contained in:
parent
7beda36d87
commit
071508e2df
@ -333,7 +333,13 @@ def media_pre_delete(sender, instance, **kwargs):
|
|||||||
@receiver(post_delete, sender=Media)
|
@receiver(post_delete, sender=Media)
|
||||||
def media_post_delete(sender, instance, **kwargs):
|
def media_post_delete(sender, instance, **kwargs):
|
||||||
# Remove the video file, when configured to do so
|
# Remove the video file, when configured to do so
|
||||||
if instance.source.delete_files_on_disk and instance.media_file:
|
remove_files = (
|
||||||
|
instance.source and
|
||||||
|
instance.source.delete_files_on_disk and
|
||||||
|
instance.downloaded and
|
||||||
|
instance.media_file
|
||||||
|
)
|
||||||
|
if remove_files:
|
||||||
video_path = Path(str(instance.media_file.path)).resolve(strict=False)
|
video_path = Path(str(instance.media_file.path)).resolve(strict=False)
|
||||||
instance.media_file.delete(save=False)
|
instance.media_file.delete(save=False)
|
||||||
# the other files we created have these known suffixes
|
# the other files we created have these known suffixes
|
||||||
@ -391,10 +397,19 @@ def media_post_delete(sender, instance, **kwargs):
|
|||||||
# Create a media entry for the indexing task to find
|
# Create a media entry for the indexing task to find
|
||||||
# Requirements:
|
# Requirements:
|
||||||
# source, key, duration, title, published
|
# source, key, duration, title, published
|
||||||
skipped_media, created = Media.objects.get_or_create(
|
created = False
|
||||||
key=instance.key,
|
create_for_indexing_task = (
|
||||||
source=instance.source,
|
not (
|
||||||
|
#not instance.downloaded and
|
||||||
|
instance.skip and
|
||||||
|
instance.manual_skip
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
if create_for_indexing_task:
|
||||||
|
skipped_media, created = Media.objects.get_or_create(
|
||||||
|
key=instance.key,
|
||||||
|
source=instance.source,
|
||||||
|
)
|
||||||
if created:
|
if created:
|
||||||
old_metadata = instance.loaded_metadata
|
old_metadata = instance.loaded_metadata
|
||||||
site_field = instance.get_metadata_field('extractor_key')
|
site_field = instance.get_metadata_field('extractor_key')
|
||||||
|
Loading…
Reference in New Issue
Block a user