@@ -621,6 +621,11 @@ def finish_build(version_pk, build_pk, hostname=None, html=False,
621
621
version .built = True
622
622
version .save ()
623
623
624
+ if not pdf :
625
+ clear_pdf_artifacts (version )
626
+ if not epub :
627
+ clear_epub_artifacts (version )
628
+
624
629
move_files (
625
630
version_pk = version_pk ,
626
631
hostname = hostname ,
@@ -661,19 +666,28 @@ def move_files(version_pk, hostname, html=False, localmedia=False, search=False,
661
666
from_path = version .project .artifact_path (version = version .slug , type = 'sphinx_localmedia' )
662
667
to_path = version .project .get_production_media_path (type = 'htmlzip' , version_slug = version .slug , include_file = False )
663
668
Syncer .copy (from_path , to_path , host = hostname )
669
+
664
670
if search :
665
671
from_path = version .project .artifact_path (version = version .slug , type = 'sphinx_search' )
666
672
to_path = version .project .get_production_media_path (type = 'json' , version_slug = version .slug , include_file = False )
667
673
Syncer .copy (from_path , to_path , host = hostname )
674
+
668
675
# Always move PDF's because the return code lies.
669
676
if pdf :
670
677
from_path = version .project .artifact_path (version = version .slug , type = 'sphinx_pdf' )
671
678
to_path = version .project .get_production_media_path (type = 'pdf' , version_slug = version .slug , include_file = False )
672
679
Syncer .copy (from_path , to_path , host = hostname )
680
+ elif not version .project .enable_pdf_build :
681
+ to_path = version .project .get_production_media_path (type = 'pdf' , version_slug = version .slug , include_file = False )
682
+ Syncer .remove (to_path )
683
+
673
684
if epub :
674
685
from_path = version .project .artifact_path (version = version .slug , type = 'sphinx_epub' )
675
686
to_path = version .project .get_production_media_path (type = 'epub' , version_slug = version .slug , include_file = False )
676
687
Syncer .copy (from_path , to_path , host = hostname )
688
+ elif not version .project .enable_epub_build :
689
+ to_path = version .project .get_production_media_path (type = 'epub' , version_slug = version .slug , include_file = False )
690
+ Syncer .remove (to_path )
677
691
678
692
if 'mkdocs' in version .project .documentation_type :
679
693
if search :
@@ -882,7 +896,23 @@ def remove_dir(path):
882
896
def clear_artifacts (version_pk ):
883
897
""" Remove artifacts from the web servers. """
884
898
version = Version .objects .get (pk = version_pk )
899
+ clear_pdf_artifacts (version )
900
+ clear_epub_artifacts (version )
901
+ clear_htmlzip_artifacts (version )
902
+ clear_html_artifacts (version )
903
+
904
+
905
+ def clear_pdf_artifacts (version ):
885
906
run_on_app_servers ('rm -rf %s' % version .project .get_production_media_path (type = 'pdf' , version_slug = version .slug ))
907
+
908
+
909
+ def clear_epub_artifacts (version ):
886
910
run_on_app_servers ('rm -rf %s' % version .project .get_production_media_path (type = 'epub' , version_slug = version .slug ))
911
+
912
+
913
+ def clear_htmlzip_artifacts (version ):
887
914
run_on_app_servers ('rm -rf %s' % version .project .get_production_media_path (type = 'htmlzip' , version_slug = version .slug ))
915
+
916
+
917
+ def clear_html_artifacts (version ):
888
918
run_on_app_servers ('rm -rf %s' % version .project .rtd_build_path (version = version .slug ))
0 commit comments