Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion server/mergin/sync/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def to_data_delta(self):
version=self.version,
)
if self.diffs:
result.diff = self.diffs[0].id
result.diff = None
return result


Expand Down
11 changes: 9 additions & 2 deletions server/mergin/sync/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,9 @@ def construct_checkpoint(self) -> bool:
return False

project: Project = basefile.file.project
os.makedirs(project.storage.diffs_dir, exist_ok=True)

# create diffs directory if not exists and subfolders in case of diffs/subfolder/diff-file
os.makedirs(os.path.dirname(self.abs_path), exist_ok=True)

try:
if len(diffs_paths) == 1:
Expand All @@ -1041,7 +1043,7 @@ def construct_checkpoint(self) -> bool:
project.storage.geodiff.concat_changes(diffs_paths, self.abs_path)
except (GeoDiffLibError, GeoDiffLibConflictError):
logging.error(
f"Geodiff: Failed to merge diffs for file {self.file_path_id}"
f"Geodiff: Failed to merge diffs for file {self.file_path_id}. Diffs: {diffs_paths}"
)
return False

Expand Down Expand Up @@ -1357,6 +1359,11 @@ def create_checkpoint(
# Patch the delta with the path to the new diff checkpoint
item.diff = checkpoint_diff.path
db.session.add(checkpoint_diff)
else:
# checkpoint already exists, just patch the delta with the path to the existing diff checkpoint
# this could happen when file diff exists but dela was missing
# this allowing us to remove rank > 0 delta checkpoints in case of inconsistencies
item.diff = existing_diff_checkpoint.path

checkpoint_delta = ProjectVersionDelta(
project_id=project_id,
Expand Down
Loading