@@ -612,6 +612,11 @@ def finish_build(version_pk, build_pk, hostname=None, html=False,
612
612
version .built = True
613
613
version .save ()
614
614
615
+ if not pdf :
616
+ clear_pdf_artifacts (version )
617
+ if not epub :
618
+ clear_epub_artifacts (version )
619
+
615
620
move_files (
616
621
version_pk = version_pk ,
617
622
hostname = hostname ,
@@ -652,19 +657,28 @@ def move_files(version_pk, hostname, html=False, localmedia=False, search=False,
652
657
from_path = version .project .artifact_path (version = version .slug , type = 'sphinx_localmedia' )
653
658
to_path = version .project .get_production_media_path (type = 'htmlzip' , version_slug = version .slug , include_file = False )
654
659
Syncer .copy (from_path , to_path , host = hostname )
660
+
655
661
if search :
656
662
from_path = version .project .artifact_path (version = version .slug , type = 'sphinx_search' )
657
663
to_path = version .project .get_production_media_path (type = 'json' , version_slug = version .slug , include_file = False )
658
664
Syncer .copy (from_path , to_path , host = hostname )
665
+
659
666
# Always move PDF's because the return code lies.
660
667
if pdf :
661
668
from_path = version .project .artifact_path (version = version .slug , type = 'sphinx_pdf' )
662
669
to_path = version .project .get_production_media_path (type = 'pdf' , version_slug = version .slug , include_file = False )
663
670
Syncer .copy (from_path , to_path , host = hostname )
671
+ elif not version .project .enable_pdf_build :
672
+ to_path = version .project .get_production_media_path (type = 'pdf' , version_slug = version .slug , include_file = False )
673
+ Syncer .remove (to_path )
674
+
664
675
if epub :
665
676
from_path = version .project .artifact_path (version = version .slug , type = 'sphinx_epub' )
666
677
to_path = version .project .get_production_media_path (type = 'epub' , version_slug = version .slug , include_file = False )
667
678
Syncer .copy (from_path , to_path , host = hostname )
679
+ elif not version .project .enable_epub_build :
680
+ to_path = version .project .get_production_media_path (type = 'epub' , version_slug = version .slug , include_file = False )
681
+ Syncer .remove (to_path )
668
682
669
683
if 'mkdocs' in version .project .documentation_type :
670
684
if search :
@@ -875,7 +889,23 @@ def remove_dir(path):
875
889
def clear_artifacts (version_pk ):
876
890
""" Remove artifacts from the web servers. """
877
891
version = Version .objects .get (pk = version_pk )
892
+ clear_pdf_artifacts (version )
893
+ clear_epub_artifacts (version )
894
+ clear_htmlzip_artifacts (version )
895
+ clear_html_artifacts (version )
896
+
897
+
898
+ def clear_pdf_artifacts (version ):
878
899
run_on_app_servers ('rm -rf %s' % version .project .get_production_media_path (type = 'pdf' , version_slug = version .slug ))
900
+
901
+
902
+ def clear_epub_artifacts (version ):
879
903
run_on_app_servers ('rm -rf %s' % version .project .get_production_media_path (type = 'epub' , version_slug = version .slug ))
904
+
905
+
906
+ def clear_htmlzip_artifacts (version ):
880
907
run_on_app_servers ('rm -rf %s' % version .project .get_production_media_path (type = 'htmlzip' , version_slug = version .slug ))
908
+
909
+
910
+ def clear_html_artifacts (version ):
881
911
run_on_app_servers ('rm -rf %s' % version .project .rtd_build_path (version = version .slug ))
0 commit comments