Remove old PDFs/ePubs when they are no longer built
@@ -938,6 +938,16 @@ def sync_files(
version_slug=version.slug,
),
])
+
+ if getattr(storage, 'write_build_media', False):
+ # Remove PDF from remote storage if it exists
+ storage_path = version.project.get_storage_path(
+ type_='pdf',
+ version_slug=version.slug,
+ )
+ if storage.exists(storage_path):
+ log.info('Removing %s from media storage', storage_path)
+ storage.delete(storage_path)
if not epub:
remove_dirs([
version.project.get_production_media_path(
@@ -946,6 +956,16 @@ def sync_files(
),
])
+ if getattr(storage, 'write_build_media', False):
+ # Remove ePub from remote storage if it exists
+ storage_path = version.project.get_storage_path(
+ type_='epub',
+ version_slug=version.slug,
+ )
+ if storage.exists(storage_path):
+ log.info('Removing %s from media storage', storage_path)
+ storage.delete(storage_path)
+
# Sync files to the web servers
move_files(
version_pk,
