Skip to content

Commit 4fab169

Browse files
committed
Remove old PDFs/ePubs when they are no longer built
1 parent a7db138 commit 4fab169

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

readthedocs/projects/tasks.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,16 @@ def sync_files(
938938
version_slug=version.slug,
939939
),
940940
])
941+
942+
if getattr(storage, 'write_build_media', False):
943+
# Remove PDF from remote storage if it exists
944+
storage_path = version.project.get_storage_path(
945+
type_='pdf',
946+
version_slug=version.slug,
947+
)
948+
if storage.exists(storage_path):
949+
log.info('Removing %s from media storage', storage_path)
950+
storage.delete(storage_path)
941951
if not epub:
942952
remove_dirs([
943953
version.project.get_production_media_path(
@@ -946,6 +956,16 @@ def sync_files(
946956
),
947957
])
948958

959+
if getattr(storage, 'write_build_media', False):
960+
# Remove ePub from remote storage if it exists
961+
storage_path = version.project.get_storage_path(
962+
type_='epub',
963+
version_slug=version.slug,
964+
)
965+
if storage.exists(storage_path):
966+
log.info('Removing %s from media storage', storage_path)
967+
storage.delete(storage_path)
968+
949969
# Sync files to the web servers
950970
move_files(
951971
version_pk,

0 commit comments

Comments
 (0)