62
62
63
63
from readthedocs .builds .models import Version
64
64
from readthedocs .core .utils .extend import SettingsOverrideObject
65
+ from readthedocs .core .utils import safe_makedirs
65
66
from readthedocs .projects import constants
66
67
from readthedocs .projects .models import Domain
67
68
from readthedocs .projects .utils import run
@@ -100,19 +101,19 @@ def sanity_check(self):
100
101
if os .path .islink (self .project_root ) and not self .project .single_version :
101
102
self ._log ("Removing single version symlink" )
102
103
os .unlink (self .project_root )
103
- os . makedirs (self .project_root )
104
+ safe_makedirs (self .project_root )
104
105
elif (self .project .single_version and
105
106
not os .path .islink (self .project_root ) and
106
107
os .path .exists (self .project_root )):
107
108
shutil .rmtree (self .project_root )
108
109
elif not os .path .lexists (self .project_root ):
109
- os . makedirs (self .project_root )
110
+ safe_makedirs (self .project_root )
110
111
111
112
# CNAME root directories
112
113
if not os .path .lexists (self .CNAME_ROOT ):
113
- os . makedirs (self .CNAME_ROOT )
114
+ safe_makedirs (self .CNAME_ROOT )
114
115
if not os .path .lexists (self .PROJECT_CNAME_ROOT ):
115
- os . makedirs (self .PROJECT_CNAME_ROOT )
116
+ safe_makedirs (self .PROJECT_CNAME_ROOT )
116
117
117
118
def run (self ):
118
119
"""
@@ -177,7 +178,7 @@ def symlink_subprojects(self):
177
178
if rels .count ():
178
179
# Don't creat the `projects/` directory unless subprojects exist.
179
180
if not os .path .exists (self .subproject_root ):
180
- os . makedirs (self .subproject_root )
181
+ safe_makedirs (self .subproject_root )
181
182
for rel in rels :
182
183
# A mapping of slugs for the subproject URL to the actual built
183
184
# documentation
@@ -194,7 +195,7 @@ def symlink_subprojects(self):
194
195
)
195
196
symlink_dir = os .sep .join (symlink .split (os .path .sep )[:- 1 ])
196
197
if not os .path .lexists (symlink_dir ):
197
- os . makedirs (symlink_dir )
198
+ safe_makedirs (symlink_dir )
198
199
run ('ln -nsf %s %s' % (docs_dir , symlink ))
199
200
200
201
# Remove old symlinks
@@ -219,7 +220,7 @@ def symlink_translations(self):
219
220
if os .path .islink (language_dir ):
220
221
os .unlink (language_dir )
221
222
if not os .path .lexists (language_dir ):
222
- os . makedirs (language_dir )
223
+ safe_makedirs (language_dir )
223
224
224
225
for (language , slug ) in translations .items ():
225
226
self ._log (u"Symlinking translation: {0}->{1}" .format (language , slug ))
@@ -271,7 +272,7 @@ def symlink_versions(self):
271
272
version_queryset = self .get_version_queryset ()
272
273
if version_queryset .count ():
273
274
if not os .path .exists (version_dir ):
274
- os . makedirs (version_dir )
275
+ safe_makedirs (version_dir )
275
276
for version in version_queryset :
276
277
self ._log (u"Symlinking Version: %s" % version )
277
278
symlink = os .path .join (version_dir , version .slug )
0 commit comments