2121
2222from .local_changes import LocalChange , LocalChanges
2323
24- from .common import UPLOAD_CHUNK_SIZE , ClientError
24+ from .common import UPLOAD_CHUNK_SIZE , ClientError , ErrorCode
2525from .merginproject import MerginProject
2626from .editor import filter_changes
2727
@@ -136,7 +136,7 @@ def upload_blocking(self):
136136 continue
137137 raise
138138
139- self .mp .log .debug (f"Upload chunk { self .chunk_id } finished: { self .file_path } " )
139+ self .mp .log .debug (f"Upload chunk { self .server_chunk_id or self . chunk_id } finished: { self .file_path } " )
140140
141141
142142class UploadJob :
@@ -188,7 +188,7 @@ def add_items(self, items: List[UploadQueueItem], total_size: int):
188188 def update_chunks_from_items (self ):
189189 """Update chunks in LocalChanges from the upload queue items."""
190190 self .changes .update_chunks (
191- [(item .file_checksum , item .server_chunk_id ) for item in self .upload_queue_items ]
191+ [(item .chunk_id , item .server_chunk_id ) for item in self .upload_queue_items ]
192192 )
193193
194194
@@ -285,9 +285,9 @@ def create_upload_job_v2_api(
285285 {"Content-Type" : "application/json" },
286286 )
287287 except ClientError as err :
288- # ignore 409 error, it means that the project is already in a transaction
288+ # ignore 409 error codes , it means that the project is already in a transaction
289289 # but we still want to continue with the upload
290- if err .http_error not in [409 ]:
290+ if err .server_code not in [ErrorCode . AnotherUploadRunning . value , ErrorCode . ProjectVersionExists ]:
291291 mp .log .error ("Error doing push check compatibility: " + str (err ))
292292 mp .log .error ("--- push aborted" )
293293 raise
@@ -439,11 +439,10 @@ def push_project_finalize(job: UploadJob):
439439 job .mp .log .error ("--- push finish failed! " + error_msg )
440440 raise ClientError ("Upload error: " + error_msg )
441441
442- job .update_chunks_from_items ()
443-
444442 if server_features .get ("v2_push_enabled" ):
445443 # v2 push uses a different endpoint
446444 try :
445+ job .update_chunks_from_items ()
447446 job .mp .log .info (f"Finishing transaction for project { job .mp .project_full_name ()} " )
448447 job .mc .post (
449448 f"/v2/projects/{ job .mp .project_id ()} /versions" ,
@@ -456,6 +455,10 @@ def push_project_finalize(job: UploadJob):
456455 project_info = job .mc .project_info (job .mp .project_id ())
457456 job .server_resp = project_info
458457 except ClientError as err :
458+ if err .server_code in [ErrorCode .AnotherUploadRunning .value , ErrorCode .ProjectVersionExists ]:
459+ err .sync_retry = True
460+ else :
461+ job .mc .upload_chunks_cache .clear () # clear the upload chunks cache, as we are getting fatal from server
459462 job .mp .log .error ("--- push finish failed! " + str (err ))
460463 raise err
461464 elif with_upload_of_files :
0 commit comments