@@ -165,14 +165,14 @@ top-level directory.
|
||||
"overviewer_core", "data", "web_assets")
|
||||
if not os.path.isdir(global_assets):
|
||||
global_assets = os.path.join(util.get_program_path(), "web_assets")
|
||||
mirror_dir(global_assets, self.outputdir, capabilities=self.fs_caps)
|
||||
mirror_dir(global_assets, self.outputdir, capabilities=self.fs_caps, force_writable=True)
|
||||
|
||||
if self.custom_assets_dir:
|
||||
# We could have done something fancy here rather than just
|
||||
# overwriting the global files, but apparently this what we used to
|
||||
# do pre-rewrite.
|
||||
mirror_dir(self.custom_assets_dir, self.outputdir,
|
||||
capabilities=self.fs_caps)
|
||||
mirror_dir(self.custom_assets_dir, self.outputdir, capabilities=self.fs_caps,
|
||||
force_writable=True)
|
||||
|
||||
# write a dummy baseMarkers.js if none exists
|
||||
basemarkers_path = os.path.join(self.outputdir, "baseMarkers.js")
|
||||
|
||||
@@ -62,7 +62,7 @@ def does_rename_work(dir_to_test):
|
||||
return renameworks
|
||||
|
||||
## useful recursive copy, that ignores common OS cruft
|
||||
def mirror_dir(src, dst, entities=None, capabilities=default_caps):
|
||||
def mirror_dir(src, dst, entities=None, capabilities=default_caps, force_writable=False):
|
||||
'''copies all of the entities from src to dst'''
|
||||
chmod_works = capabilities.get("chmod_works")
|
||||
if not os.path.exists(dst):
|
||||
@@ -80,11 +80,14 @@ def mirror_dir(src, dst, entities=None, capabilities=default_caps):
|
||||
continue
|
||||
|
||||
if os.path.isdir(os.path.join(src,entry)):
|
||||
mirror_dir(os.path.join(src, entry), os.path.join(dst, entry), capabilities=capabilities)
|
||||
mirror_dir(os.path.join(src, entry), os.path.join(dst, entry), capabilities=capabilities, force_writable=force_writable)
|
||||
elif os.path.isfile(os.path.join(src,entry)):
|
||||
try:
|
||||
if chmod_works:
|
||||
shutil.copy(os.path.join(src, entry), os.path.join(dst, entry))
|
||||
if force_writable: # for shitty neckbeard ware
|
||||
dst_stat = os.stat(os.path.join(dst, entry))
|
||||
os.chmod(os.path.join(dst, entry), dst_stat.st_mode | stat.S_IWUSR)
|
||||
else:
|
||||
shutil.copyfile(os.path.join(src, entry), os.path.join(dst, entry))
|
||||
except IOError as outer:
|
||||
@@ -99,6 +102,9 @@ def mirror_dir(src, dst, entities=None, capabilities=default_caps):
|
||||
# try again; if this stills throws an error, let it propagate up
|
||||
if chmod_works:
|
||||
shutil.copy(os.path.join(src, entry), os.path.join(dst, entry))
|
||||
if force_writable:
|
||||
dst_stat = os.stat(os.path.join(dst, entry))
|
||||
os.chmod(os.path.join(dst, entry), dst_stat.st_mode | stat.S_IWUSR)
|
||||
else:
|
||||
shutil.copyfile(os.path.join(src, entry), os.path.join(dst, entry))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user