Skip to content

Commit

Permalink
Fix for the issue #55.
Browse files Browse the repository at this point in the history
  • Loading branch information
ldebek committed Apr 19, 2023
1 parent aae986c commit e942313
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions workpackages/wp_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ class ProjectPadlock:
This allows to prevent editing projects by other users while mergin-work-packages script is running.
"""

LOCK_EXPIRED_MESSAGE = (
"The requested URL was not found on the server. "
"If you entered the URL manually please check your spelling and try again."
)

def __init__(self, mc):
self.mc = mc
self.locked_projects = {}
Expand Down Expand Up @@ -73,8 +78,12 @@ def unlock(self, directory):
try:
self.mc.post(f"/v1/project/push/cancel/{locked_transaction_id}")
except mergin.ClientError as err:
print("--- push cancelling failed! " + str(err))
raise err
error_message = str(err)
if self.LOCK_EXPIRED_MESSAGE in error_message:
print("--- push cancelling skipped as project lock expired automatically")
else:
print("--- push cancelling failed! " + error_message)
raise err
del self.locked_projects[directory]
print(f"--- released locked dir: '{directory}' (transaction ID: {locked_transaction_id})")

Expand Down

0 comments on commit e942313

Please sign in to comment.