Skip to content

Conversation

MarcelGeo
Copy link
Collaborator

@MarcelGeo MarcelGeo commented Oct 9, 2025

We are introducing new table for storing chckpoints (project_version_change), where rank and delta json for current version is stored. If version are in logarithms logic with base=4, then store higher level checkpoints if needed.

Structure for delta json: List[DeltaData]. If there is not diff, diff key is not provided in result.

[
  {
    "diff": "Survey_points.gpkg-diff-14ee7fe7-366a-4ba8-85f3-f15c38242d93",
    "path": "Survey_points.gpkg",
    "size": 98304,
    "change": "update_diff",
    "version":  25,
    "checksum": "12b26ef4ed11e4fb411baf40402fedf26696f830"
  }
]

Delta creation logic

  • if new version is created, Project version change with delta and rank=0 is created
  • if somebody will return changes which will be aplied in /delta endpoint, checkpoints are created or returned if exists
  • as side effect, If checkpoint does not exists, FileDiff new file future geodiff file name is generated in FileDiff table

Migration

Migrate file history and file diffs to merged delta in project_version_change table.

@MarcelGeo MarcelGeo requested a review from varmar05 October 9, 2025 16:24
@coveralls
Copy link

coveralls commented Oct 9, 2025

Pull Request Test Coverage Report for Build 18385680927

Details

  • 292 of 299 (97.66%) changed or added relevant lines in 5 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.1%) to 94.376%

Changes Missing Coverage Covered Lines Changed/Added Lines %
server/mergin/sync/public_api_v2_controller.py 14 15 93.33%
server/mergin/tests/utils.py 1 2 50.0%
server/mergin/sync/models.py 98 103 95.15%
Files with Coverage Reduction New Missed Lines %
server/mergin/tests/utils.py 1 96.48%
Totals Coverage Status
Change from base Build 18221816068: 0.1%
Covered Lines: 8391
Relevant Lines: 8891

💛 - Coveralls

PushChangeType.UPDATE,
PushChangeType.UPDATE_DIFF,
):
# create + update = create with updated info
Copy link
Collaborator

Choose a reason for hiding this comment

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

yes, for client this is completely new file so any subsequent updates will appear as a new file to client, just with the most recent metadata - pleas update a comment

current.change = existing.change
current.diffs = []
else:
result[path] = current
Copy link
Collaborator

Choose a reason for hiding this comment

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

ideally this should never happen? - create + create

current.diffs.extend(existing.diffs or [])
result[path] = current
else:
# delete + anything = anything
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think so - after delete we should only have a create action, otherwise we have weird inconsistent history - I'd be more specific here.

elif existing.change == PushChangeType.UPDATE_DIFF:
if current.change == PushChangeType.UPDATE_DIFF:
# update_diff + update_diff = update_diff with latest info
current.diffs.extend(existing.diffs or [])
Copy link
Collaborator

Choose a reason for hiding this comment

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

should not we extend previous.diffs with current diff(s)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

renamed to previous

Copy link
Collaborator

Choose a reason for hiding this comment

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

the comment was about making sure that order of diffs in list is correct

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

let's upgrade diffs existing first, current last

- rename table to project version delta with column changes
- rename classes
- add get_delta_changes to project instance (nice)
- fix migration to int
@MarcelGeo MarcelGeo requested a review from varmar05 October 10, 2025 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants