63
63
64
64
from readthedocs .builds .models import Version
65
65
from readthedocs .core .utils .extend import SettingsOverrideObject
66
- from readthedocs .core .utils import safe_makedirs
66
+ from readthedocs .core .utils import safe_makedirs , safe_unlink
67
67
from readthedocs .projects import constants
68
68
from readthedocs .projects .models import Domain
69
69
from readthedocs .projects .utils import run
@@ -95,7 +95,7 @@ def sanity_check(self):
95
95
log .info (constants .LOG_TEMPLATE .format (
96
96
project = self .project .slug , version = '' ,
97
97
msg = "Removing single version symlink" ))
98
- os . unlink (self .project_root )
98
+ safe_unlink (self .project_root )
99
99
safe_makedirs (self .project_root )
100
100
elif (self .project .single_version and
101
101
not os .path .islink (self .project_root ) and
@@ -164,7 +164,7 @@ def remove_symlink_cname(self, domain):
164
164
log .info (constants .LOG_TEMPLATE .format (project = self .project .slug ,
165
165
version = '' , msg = log_msg ))
166
166
symlink = os .path .join (self .CNAME_ROOT , domain .domain )
167
- os . unlink (symlink )
167
+ safe_unlink (symlink )
168
168
169
169
def symlink_subprojects (self ):
170
170
"""
@@ -210,7 +210,7 @@ def symlink_subprojects(self):
210
210
if os .path .exists (self .subproject_root ):
211
211
for subproj in os .listdir (self .subproject_root ):
212
212
if subproj not in subprojects :
213
- os . unlink (os .path .join (self .subproject_root , subproj ))
213
+ safe_unlink (os .path .join (self .subproject_root , subproj ))
214
214
215
215
def symlink_translations (self ):
216
216
"""
@@ -227,7 +227,7 @@ def symlink_translations(self):
227
227
# Make sure the language directory is a directory
228
228
language_dir = os .path .join (self .project_root , self .project .language )
229
229
if os .path .islink (language_dir ):
230
- os . unlink (language_dir )
230
+ safe_unlink (language_dir )
231
231
if not os .path .lexists (language_dir ):
232
232
safe_makedirs (language_dir )
233
233
@@ -246,7 +246,7 @@ def symlink_translations(self):
246
246
lang not in ['projects' , self .project .language ]):
247
247
to_delete = os .path .join (self .project_root , lang )
248
248
if os .path .islink (to_delete ):
249
- os . unlink (to_delete )
249
+ safe_unlink (to_delete )
250
250
else :
251
251
shutil .rmtree (to_delete )
252
252
@@ -262,7 +262,7 @@ def symlink_single_version(self):
262
262
# Clean up symlinks
263
263
symlink = self .project_root
264
264
if os .path .islink (symlink ):
265
- os . unlink (symlink )
265
+ safe_unlink (symlink )
266
266
if os .path .exists (symlink ):
267
267
shutil .rmtree (symlink )
268
268
@@ -300,7 +300,7 @@ def symlink_versions(self):
300
300
if os .path .exists (version_dir ):
301
301
for old_ver in os .listdir (version_dir ):
302
302
if old_ver not in versions :
303
- os . unlink (os .path .join (version_dir , old_ver ))
303
+ safe_unlink (os .path .join (version_dir , old_ver ))
304
304
305
305
def get_default_version (self ):
306
306
"""Look up project default version, return None if not found."""
0 commit comments