@@ -1512,7 +1512,7 @@ def create_invitation(self, workspace_id: int, email: str, workspace_role: Works
15121512 ws_inv = self .post (f"v2/workspaces/{ workspace_id } /invitations" , params , json_headers )
15131513 return json .load (ws_inv )
15141514
1515- def sync_project (self , project_directory , upload_progress = False ):
1515+ def sync_project_generator (self , project_directory ):
15161516 """
15171517 Syncs project by loop with these steps:
15181518 1. Pull server version
@@ -1521,30 +1521,23 @@ def sync_project(self, project_directory, upload_progress=False):
15211521 Repeat if there are more local changes.
15221522
15231523 :param project_directory: Project's directory
1524- :param upload_progress: If True, the method will be a generator yielding upload progress as (size_change, job) tuples.
15251524 """
15261525 mp = MerginProject (project_directory )
15271526 has_changes = True
15281527 server_conflict_attempts = 0
15291528 while has_changes :
1530- pull_job = pull_project_async (self , project_directory )
1531- if pull_job :
1532- pull_project_wait (pull_job )
1533- pull_project_finalize (pull_job )
1534-
1529+ self .pull_project (project_directory )
15351530 try :
15361531 job = push_project_async (self , project_directory )
15371532 if not job :
15381533 break
1539- if not upload_progress :
1540- push_project_wait (job )
1541- else :
1542- last_size = 0
1543- while push_project_is_running (job ):
1544- sleep (SYNC_CALLBACK_WAIT )
1545- current_size = job .transferred_size
1546- yield (current_size - last_size , job ) # Yields the size change and the job object
1547- last_size = current_size
1534+ # waiting for progress
1535+ last_size = 0
1536+ while push_project_is_running (job ):
1537+ sleep (SYNC_CALLBACK_WAIT )
1538+ current_size = job .transferred_size
1539+ yield (current_size - last_size , job ) # Yields the size change and the job object
1540+ last_size = current_size
15481541 push_project_finalize (job )
15491542 _ , has_changes = get_push_changes_batch (self , mp )
15501543 server_conflict_attempts = 0
@@ -1558,3 +1551,14 @@ def sync_project(self, project_directory, upload_progress=False):
15581551 sleep (PUSH_ATTEMPT_WAIT )
15591552 continue
15601553 raise e
1554+
1555+ def sync_project (self , project_directory ):
1556+ """
1557+ See description of _sync_project_generator().
1558+
1559+ :param project_directory: Project's directory
1560+ """
1561+ # walk through the generator to perform the sync
1562+ # in this method we do not yield anything to the caller
1563+ for _ in self .sync_project_generator (project_directory ):
1564+ pass
0 commit comments