mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Change behavior of DELETE_OUTPUT_DIRECTORY to purge contents of the directory, not the directory itself.
Added Debug level logging for each deletion Added error level logging when a delete has an exception Built a test case for clean_output_directory in tests.utils.py Updated `settings` in documentation to reflect new behavior Removed the tip from the bottom of getting started since this setting should no longer break web servers pointing to the output directory.
This commit is contained in:
parent
76f86fb3ca
commit
d589450200
4 changed files with 29 additions and 8 deletions
|
|
@ -92,10 +92,22 @@ def clean_output_dir(path):
|
|||
"""Remove all the files from the output directory"""
|
||||
|
||||
# remove all the existing content from the output folder
|
||||
try:
|
||||
shutil.rmtree(path)
|
||||
except Exception:
|
||||
pass
|
||||
for filename in os.listdir(path):
|
||||
file = os.path.join(path, filename)
|
||||
if os.path.isdir(file):
|
||||
logger.debug("Deleting directory %s" % file)
|
||||
try:
|
||||
shutil.rmtree(file)
|
||||
except Exception, e:
|
||||
logger.error("Unable to delete directory %s; %e" % file, e)
|
||||
elif os.path.isfile(file) or os.path.islink(file):
|
||||
logger.debug("Deleting file/link %s" % file)
|
||||
try:
|
||||
os.remove(file)
|
||||
except Exception, e:
|
||||
logger.error("Unable to delete file %s; %e" % file, e)
|
||||
else:
|
||||
logger.error("Unable to delete %s, file type unknown" % file)
|
||||
|
||||
|
||||
def get_relative_path(filename):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue