Dont delete root web output
This commit is contained in:
parent
c3ca25a0b6
commit
52afc04fb6
|
@ -44,7 +44,7 @@ def get_value(name, default=False):
|
||||||
return default
|
return default
|
||||||
|
|
||||||
|
|
||||||
def rmrf(path):
|
def rmrf(path, keep_root=False):
|
||||||
""" Use safe-rm for recursive removal """
|
""" Use safe-rm for recursive removal """
|
||||||
""" @TODO: make it safer """
|
""" @TODO: make it safer """
|
||||||
def remove_readonly(func, path, excinfo):
|
def remove_readonly(func, path, excinfo):
|
||||||
|
@ -53,6 +53,11 @@ def rmrf(path):
|
||||||
# Try removal
|
# Try removal
|
||||||
if os.path.exists(path) and len(os.path.realpath(path)) > 1:
|
if os.path.exists(path) and len(os.path.realpath(path)) > 1:
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
|
if keep_root:
|
||||||
|
for root, dirs, files in os.walk(path):
|
||||||
|
for f in files:
|
||||||
|
os.remove(os.path.join(root, f))
|
||||||
|
else:
|
||||||
shutil.rmtree(path, onerror=remove_readonly)
|
shutil.rmtree(path, onerror=remove_readonly)
|
||||||
elif os.path.isfile(path):
|
elif os.path.isfile(path):
|
||||||
os.remove(path)
|
os.remove(path)
|
||||||
|
@ -68,7 +73,7 @@ def cmd(parts, cwd=None, env=None):
|
||||||
|
|
||||||
def hugo(hugo_site_path, dest, hugo_environment='gitea', base_url=None):
|
def hugo(hugo_site_path, dest, hugo_environment='gitea', base_url=None):
|
||||||
""" builds the website to "dest" using "tmp" as an intermediate location """
|
""" builds the website to "dest" using "tmp" as an intermediate location """
|
||||||
rmrf(dest)
|
rmrf(dest, keep_root=True)
|
||||||
try:
|
try:
|
||||||
os.makedirs(dest, exist_ok=True)
|
os.makedirs(dest, exist_ok=True)
|
||||||
except:
|
except:
|
||||||
|
|
Loading…
Reference in New Issue