mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Merge pull request #529 from bstpierre/delete-output-dir
Fix DELETE_OUTPUT_DIRECTORY crash when no output dir
This commit is contained in:
commit
cf40006b58
2 changed files with 24 additions and 0 deletions
|
|
@ -97,6 +97,17 @@ def copy(path, source, destination, destination_path=None, overwrite=False):
|
|||
def clean_output_dir(path):
|
||||
"""Remove all the files from the output directory"""
|
||||
|
||||
if not os.path.exists(path):
|
||||
logger.debug("Directory already removed: %s" % path)
|
||||
return
|
||||
|
||||
if not os.path.isdir(path):
|
||||
try:
|
||||
os.remove(path)
|
||||
except Exception, e:
|
||||
logger.error("Unable to delete file %s; %e" % path, e)
|
||||
return
|
||||
|
||||
# remove all the existing content from the output folder
|
||||
for filename in os.listdir(path):
|
||||
file = os.path.join(path, filename)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue