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

This commit is contained in:
Wolf-Bastian Poettner 2020-02-01 13:26:49 +00:00
parent 26b20cf62e
commit e79f5394fc

View File

@ -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