Make theme dir writable after copying to it
In certain settings (i.e. when using the nix package manager), program files are stored as read-only. Hence, copying the themes from there will result in read-only directories in the output directory, making subsequent operations fail due to permission errors. There does not seem to be a way to let `shutil.copytree` "forget" permissions, so we adapt them after the fact.
This commit is contained in:
@@ -24,6 +24,7 @@ import importlib
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
import stat
|
||||
import sys
|
||||
import types
|
||||
|
||||
@@ -105,6 +106,15 @@ class AbstractWriter:
|
||||
):
|
||||
shutil.copytree(static_path, self.theme_path, dirs_exist_ok=True)
|
||||
|
||||
# Ensure that the theme dir is writeable
|
||||
for root, _, files in os.walk(self.theme_path):
|
||||
st = os.stat(root)
|
||||
os.chmod(root, st.st_mode | stat.S_IWUSR)
|
||||
for name in files:
|
||||
path = os.path.join(root, name)
|
||||
st = os.stat(path)
|
||||
os.chmod(path, st.st_mode | stat.S_IWUSR)
|
||||
|
||||
if self.settings["user_css"]:
|
||||
if not os.path.exists(self.settings["user_css"]):
|
||||
self.logger.error(
|
||||
|
||||
Reference in New Issue
Block a user