Browse files

Log a warning when a file is overwritten.

  • Loading branch information...
EnigmaCurry committed Mar 2, 2011
1 parent 94eb28b commit e819e8dc787a6f43d70d265d2b73cc7a3e0118c2
Showing with 6 additions and 1 deletion.
  1. +2 −1 blogofile/site_init/
  2. +4 −0 blogofile/
@@ -40,7 +40,8 @@
# This is turned off by default though, because hard links are not
# necessarily what every user wants.
site.use_hard_links = False
+#Warn when we're overwriting a file?
+site.overwrite_warning = True
# These are the default ignore patterns for excluding files and dirs
# from the _site directory
# These can be strings or compiled patterns.
@@ -115,6 +115,8 @@ def __write_files(self):
#Copy this non-template file
f_path = util.path_join(root, t_fn)
logger.debug("Copying file: " + f_path)
+ if and os.path.exists(path):
+ logger.warn("Location is used more than once: {0}".format(f_path))
out_path = util.path_join(self.output_dir, f_path)
# Try hardlinking first, and if that fails copy
@@ -168,6 +170,8 @@ def materialize_template(self, template_name, location, attrs={}, lookup=None):
path = util.path_join(self.output_dir, location)
#Create the path if it doesn't exist:
+ if and os.path.exists(path):
+ logger.warn("Location is used more than once: {0}".format(location))
f = open(path, "w")

4 comments on commit e819e8d

Would this be backwards incompatible? i.e. if overwrite_warning doesn't exist in the _config. Would this be better?

if getattr(, 'overwrite_warning', False) and os.path.exists(path):
     # ...

Unless I've missed somewhere that sets default values for missing configs?


EnigmaCurry replied Mar 2, 2011

Yep, thanks!


EnigmaCurry replied Mar 2, 2011

Actually I take that back, it will be compatible. the configuration is distributed with Blogofile and this change is in the writer, which is part of Blogofile.


Please sign in to comment.