Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/studiolibrary/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import tempfile
import platform
import threading
import time
import traceback
import collections
import distutils.version
Expand Down Expand Up @@ -789,9 +790,15 @@ def write(path, data):

# Use the tmp file to check for concurrent writes
if os.path.exists(tmp):
msg = "The path is locked for writing and cannot be accessed {}"
msg = msg.format(tmp)
raise IOError(msg)
if time.time() - os.path.getmtime(tmp) > 60:
# file might remain after an abrupt program termination or partial
# synchronization with a remote storage, if the file is still
# open, there will be exception on deletion
silentRemove(tmp)
else:
msg = "The path is locked for writing and cannot be accessed {}"
msg = msg.format(tmp)
raise IOError(msg)

# Safely write the data to a tmp file and then rename to the given path
try:
Expand Down