Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for the issue #55. #56

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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: 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."
)

Comment on lines +41 to +45
Copy link
Contributor

Choose a reason for hiding this comment

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

I would probably feel safer if we just check for single line, maybe only "The requested URL was not found on the server"

@varmar05 for mergin-server, do we have some alpha-number error-code system in place?

Copy link
Contributor

Choose a reason for hiding this comment

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

We do, but is implemented only partially (mostly for limits errors).

I guess this message comes with 404 and it is auto generated by connexion lib (validation above flask level).

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