From f911d06823e84fbec48b0dbcee9ef43b51888b9b Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Tue, 8 Jul 2014 15:42:24 -0400 Subject: [PATCH] Add the option to suppress or not exceptions during deletion --- mayan/apps/common/utils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mayan/apps/common/utils.py b/mayan/apps/common/utils.py index 706ff199df..0c8d6ec103 100644 --- a/mayan/apps/common/utils.py +++ b/mayan/apps/common/utils.py @@ -454,11 +454,14 @@ def load_backend(backend_string): raise -def fs_cleanup(filename): +def fs_cleanup(filename, suppress_exceptions=True): """ Tries to remove the given filename. Ignores non-existent files """ try: os.remove(filename) except OSError: - pass + if suppress_exceptions: + pass + else: + raise