Skip to content

Commit

Permalink
unlink creates race conditions
Browse files Browse the repository at this point in the history
If (usual case) there are multiple files in a directory,
then there is a race condition to create the directory, multiple
instances will see the directory is not there, and will run makedirs
to create it. the "loser" just won't create the directory... but with
unlink... the unlink fails (because directory exists.) and
then the operation fails. (not retried? FIXME?)

So I think it's better to leave that failure mode to humans.
  • Loading branch information
petersilva committed Jan 10, 2025
1 parent c2467c1 commit 98c55eb
Showing 1 changed file with 0 additions and 8 deletions.
8 changes: 0 additions & 8 deletions sarracenia/flow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1654,8 +1654,6 @@ def mkdir(self, msg) -> bool:

if not os.path.isdir(msg['new_dir']):
try:
if os.path.exists(msg['new_dir']):
os.unlink(msg['new_dir'])
os.makedirs(msg['new_dir'], self.o.permDirDefault, True)
except Exception as ex:
logger.warning("making %s: %s" % (msg['new_dir'], ex))
Expand Down Expand Up @@ -1706,9 +1704,6 @@ def link1file(self, msg, symbolic=True) -> bool:

if not os.path.isdir(msg['new_dir']):
try:
if os.path.exists(msg['new_dir']):
os.unlink(msg['new_dir'])

self.worklist.directories_ok.append(msg['new_dir'])
os.makedirs(msg['new_dir'], self.o.permDirDefault, True)
except Exception as ex:
Expand Down Expand Up @@ -1775,9 +1770,6 @@ def do_download(self) -> None:

if not os.path.isdir(msg['new_dir']):
try:
if os.path.exists(msg['new_dir']):
os.unlink(msg['new_dir'])

logger.debug( f"missing destination directories, makedirs: {msg['new_dir']} " )
self.worklist.directories_ok.append(msg['new_dir'])
os.makedirs(msg['new_dir'], 0o775, True)
Expand Down

0 comments on commit 98c55eb

Please sign in to comment.