@@ -998,64 +998,28 @@ def move_files(
998
998
return
999
999
1000
1000
# This is False if we have already synced media files to blob storage
1001
- # We set `epub=False` for example so data doesn't get re-uploaded on each web,
1002
- # so we need this to protect against deleting in those cases
1001
+ # We set `epub=False` for example so data doesn't get re-uploaded on each
1002
+ # web, so we need this to protect against deleting in those cases
1003
1003
if delete_unsynced_media :
1004
-
1005
- if not pdf :
1006
-
1007
- remove_dirs ([
1008
- version .project .get_production_media_path (
1009
- type_ = 'pdf' ,
1010
- version_slug = version .slug ,
1011
- include_file = False ,
1012
- ),
1013
- ])
1014
-
1015
- if getattr (storage , 'write_build_media' , False ):
1016
- # Remove PDF from remote storage if it exists
1017
- storage_path = version .project .get_storage_path (
1018
- type_ = 'pdf' ,
1019
- version_slug = version .slug ,
1020
- )
1021
- if storage .exists (storage_path ):
1022
- log .info ('Removing %s from media storage' , storage_path )
1023
- storage .delete (storage_path )
1024
-
1025
- if not epub :
1026
-
1027
- remove_dirs ([
1028
- version .project .get_production_media_path (
1029
- type_ = 'epub' ,
1030
- version_slug = version .slug ,
1031
- include_file = False ,
1032
- ),
1033
- ])
1034
-
1035
- if getattr (storage , 'write_build_media' , False ):
1036
- # Remove ePub from remote storage if it exists
1037
- storage_path = version .project .get_storage_path (
1038
- type_ = 'epub' ,
1039
- version_slug = version .slug ,
1040
- )
1041
- if storage .exists (storage_path ):
1042
- log .info ('Removing %s from media storage' , storage_path )
1043
- storage .delete (storage_path )
1044
-
1045
- if not localmedia :
1046
-
1004
+ downloads = {
1005
+ 'pdf' : pdf ,
1006
+ 'epub' : epub ,
1007
+ 'htmlzip' : localmedia ,
1008
+ }
1009
+ unsync_downloads = (k for k , v in downloads .items () if not v )
1010
+ for media_type in unsync_downloads :
1047
1011
remove_dirs ([
1048
1012
version .project .get_production_media_path (
1049
- type_ = 'htmlzip' ,
1013
+ type_ = media_type ,
1050
1014
version_slug = version .slug ,
1051
1015
include_file = False ,
1052
1016
),
1053
1017
])
1054
1018
1055
1019
if getattr (storage , 'write_build_media' , False ):
1056
- # Remove ePub from remote storage if it exists
1020
+ # Remove the media from remote storage if it exists
1057
1021
storage_path = version .project .get_storage_path (
1058
- type_ = 'htmlzip' ,
1022
+ type_ = media_type ,
1059
1023
version_slug = version .slug ,
1060
1024
)
1061
1025
if storage .exists (storage_path ):
@@ -1104,7 +1068,6 @@ def move_files(
1104
1068
include_file = True ,
1105
1069
)
1106
1070
Syncer .copy (from_path , to_path , host = hostname , is_file = True )
1107
- # Always move PDF's because the return code lies.
1108
1071
if pdf :
1109
1072
from_path = os .path .join (
1110
1073
version .project .artifact_path (
0 commit comments