Skip to content

Commit 06e815e

Browse files
committed
Reloading MerginProject instance to get fresh changes
1 parent cac700e commit 06e815e

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

mergin/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1539,7 +1539,7 @@ def sync_project_generator(self, project_directory):
15391539
yield (current_size - last_size, job) # Yields the size change and the job object
15401540
last_size = current_size
15411541
push_project_finalize(job)
1542-
_, has_changes = get_push_changes_batch(self, mp)
1542+
_, has_changes = get_push_changes_batch(self, project_directory)
15431543
server_conflict_attempts = 0
15441544
except ClientError as e:
15451545
if e.is_retryable_sync() and server_conflict_attempts < PUSH_ATTEMPTS - 1:

mergin/client_push.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ def push_project_async(mc, directory) -> Optional[UploadJob]:
303303

304304
mp.log.info(f"got project info: local version {local_version}")
305305

306-
changes, changes_len = get_push_changes_batch(mc, mp)
306+
changes, changes_len = get_push_changes_batch(mc, directory)
307307
if not changes_len:
308308
mp.log.info(f"--- push {project_path} - nothing to do")
309309
return
@@ -479,10 +479,11 @@ def remove_diff_files(job: UploadJob) -> None:
479479
os.remove(diff_file)
480480

481481

482-
def get_push_changes_batch(mc, mp: MerginProject) -> Tuple[LocalProjectChanges, int]:
482+
def get_push_changes_batch(mc, directory: str) -> Tuple[LocalProjectChanges, int]:
483483
"""
484484
Get changes that need to be pushed to the server.
485485
"""
486+
mp = MerginProject(directory)
486487
changes = mp.get_push_changes()
487488
project_role = mp.project_role()
488489
changes = filter_changes(mc, project_role, changes)
@@ -497,4 +498,7 @@ def get_push_changes_batch(mc, mp: MerginProject) -> Tuple[LocalProjectChanges,
497498
raise ClientError(
498499
f"Some files exceeded maximum upload size. Files: {', '.join([c.path for c in e.invalid_changes])}. Maximum size for media files is {MAX_UPLOAD_MEDIA_SIZE / (1024**3)} GB and for geopackage files {MAX_UPLOAD_VERSIONED_SIZE / (1024**3)} GB."
499500
)
501+
mp.log.info("-- Push changes --")
502+
mp.log.info(pprint.pformat(changes))
503+
mp.log.info(sum(len(v) for v in changes.values()))
500504
return local_changes, sum(len(v) for v in changes.values())

0 commit comments

Comments
 (0)