From 27cbdc57bc2f12a8e68293dbab6f1c21ba0e3739 Mon Sep 17 00:00:00 2001 From: Dan Puttick Date: Thu, 13 Jul 2017 12:55:26 -0400 Subject: [PATCH] Fix FileBase.make_dangerous filename editing * make_dangerous should only modify the filename if the file wasn't previously identified as dangerous * add_description should only be called if a reason_string is supplied --- kittengroomer/helpers.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kittengroomer/helpers.py b/kittengroomer/helpers.py index 85f50d1..228b8bb 100644 --- a/kittengroomer/helpers.py +++ b/kittengroomer/helpers.py @@ -157,8 +157,9 @@ class FileBase(object): """ if not self.is_dangerous: self.set_property('dangerous', True) - self.add_description(reason_string) - self.filename = 'DANGEROUS_{}_DANGEROUS'.format(self.filename) + self.filename = 'DANGEROUS_{}_DANGEROUS'.format(self.filename) + if reason_string: + self.add_description(reason_string) def safe_copy(self, src=None, dst=None): """Copy file and create destination directories if needed.""" @@ -167,6 +168,7 @@ class FileBase(object): if dst is None: dst = self.dst_path try: + # TODO: maybe don't check and just mkdir? Is there a way to do this that won't raise an Exception? Can we make shutil automatically make dirs inbetween? if not os.path.exists(self.dst_dir): os.makedirs(self.dst_dir) shutil.copy(src, dst)