WIP: Fix sync loop for too long path - #316
Open
harminius wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes MerginMaps/qgis-plugin#932
Every opened gpkg is treated as potentially updated, and we rely on geodiff to calculate the real changes. Geodiff creates an empty diff file even when there is no change.
The root cause of the issue is that geodiff's create_changeset() fails because it's not possible to create the diff file due to the filename length limit. It then uploads the whole file, but the change is still pending, so it tries indefinitely.
python-api-client/mergin/merginproject.py
Line 697 in e1d97cb
This is a minimal fix for the issue.
There are other enhancements/issue mitigations:
Store diff files locally under a short, flat name, decoupled from the file's path in the project — e.g. .mergin/diffs/ instead of .mergin/-diff-. Fixes works esp. for files nested deep in the subfolders. This does not require server changes - the server doesn't care what we call the local file.
Safeguard for any infinity sync loop
sync_project_generator'swhile has_changeshas no iteration limit. Track, per file, how many consecutive iterations it was pushed as a full upload with no diff; if the same versioned file does this N times in a row (e.g. 2–3), raise a ClientError naming the file instead of continuing. This is cause-agnostic - it also protects against any other future reason a changeset can't be computed.Long path error workaround
Use
\\?\-prefixed paths for geodiff calls and other file I/O once a resolved path is close to/over MAX_PATH. This is the only thing that helps when the diff file path is what's too long. Verified to work with our pinned geodiff/pygeodiff version; requires care to always pass fully-normalized absolute paths once prefixed. This is more invasive.