Skip to content

Commit

Permalink
packMediaDB: fix os.makedirs for existing dirs
Browse files Browse the repository at this point in the history
Ref: os.makedirs(tempfolder, exist_ok=True)
  • Loading branch information
drfho authored Sep 26, 2023
1 parent 3481028 commit 06242c8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Products/zms/_mediadb.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def manage_packMediaDb(self, REQUEST=None, RESPONSE=None):
filenames = mediadb.valid_filenames()
standard.writeLog( self, "[manage_packMediaDb]: filenames %s"%str(filenames))
tempfolder = tempfile.mkdtemp()
os.makedirs(tempfolder)
os.makedirs(tempfolder, exist_ok=True)
standard.writeLog( self, "[manage_packMediaDb]: tempfolder %s"%tempfolder)

# Traverse existing structure.
Expand Down

1 comment on commit 06242c8

@drfho
Copy link
Contributor Author

@drfho drfho commented on 06242c8 Sep 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the call of tempfile.mkdtemp() might make os.makedirs() redundant and thus provoke an error if the already existing path is not ok (param: exist_ok avoid it)

Traceback (innermost last):
  Module ZPublisher.WSGIPublisher, line 167, in transaction_pubevents
  Module ZPublisher.WSGIPublisher, line 376, in publish_module
  Module ZPublisher.WSGIPublisher, line 271, in publish
  Module ZPublisher.mapply, line 85, in mapply
  Module ZPublisher.WSGIPublisher, line 68, in call_object
  Module Products.zms._confmanager, line 703, in manage_customizeSystem
  Module Products.zms._mediadb, line 173, in manage_packMediaDb
  Module os, line 223, in makedirs
FileExistsError: [Errno 17] File exists: '/tmp/tmplgd_7ckc'

Please sign in to comment.