Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Removed try-catch around os.makedirs and used exist_ok=True instead

Wolf-Bastian Poettnere79f5394fc0e
diff --git a/src/documents/models.py b/src/documents/models.py
index a5e3a6361..1c7905643 100644
--- a/src/documents/models.py
+++ b/src/documents/models.py
@@ -335,13 +335,9 @@ class Document(models.Model):
if self.storage_type == self.STORAGE_TYPE_GPG:
filename += ".gpg"
- # Create directory for target
+ # Create directory for target (and ignore, if directory exists already)
create_dir = self.filename_to_path(slugify(directory))
- try:
- os.makedirs(create_dir)
- except os.error:
- # Directory existed already, ignore
- pass
+ os.makedirs(create_dir, exist_ok=True)
return filename