@@ -83,6 +83,38 @@ def upload_blocking(self, mc, mp):
8383 raise ClientError ("Mismatch between uploaded file chunk {} and local one" .format (self .chunk_id ))
8484
8585
86+ class UploadChanges :
87+ def __init__ (self , added = None , updated = None , removed = None ):
88+ self .added = added or []
89+ self .updated = updated or []
90+ self .removed = removed or []
91+ self .renamed = []
92+
93+ def is_empty (self ):
94+ return not (self .added or self .updated or self .removed or self .renamed )
95+
96+ def split (self ):
97+ blocking = UploadChanges ()
98+ non_blocking = UploadChanges ()
99+
100+ for file in self .added :
101+ target = blocking if is_qgis_file (file ["path" ]) or is_versioned_file (file ["path" ]) else non_blocking
102+ target .added .append (file )
103+
104+ for file in self .updated :
105+ blocking .updated .append (file )
106+
107+ for file in self .removed :
108+ blocking .removed .append (file )
109+
110+ result = {}
111+ if not blocking .is_empty ():
112+ result ["blocking" ] = blocking
113+ if not non_blocking .is_empty ():
114+ result ["non_blocking" ] = non_blocking
115+ return result
116+
117+
86118def push_project_async (mc , directory ):
87119 """Starts push of a project and returns pending upload job"""
88120
@@ -124,21 +156,22 @@ def push_project_async(mc, directory):
124156 changes = mp .get_push_changes ()
125157 changes = filter_changes (mc , project_info , changes )
126158
127- blocking_changes , non_blocking_changes = split_changes ( changes )
159+ blocking_changes , non_blocking_changes = changes . split ( )
128160
129161 blocking_job = (
130162 _prepare_upload_job (mp , mc , project_path , local_version , blocking_changes )
131163 if any (len (v ) for v in blocking_changes .values ())
132164 else None
133165 )
134166 non_blocking_job = (
135- _prepare_upload_job (mp , mc , project_path , local_version , non_blocking_changes )
167+ _prepare_upload_job (mp , mc , project_path , local_version , non_blocking_changes )
136168 if any (len (v ) for v in non_blocking_changes .values ())
137169 else None
138170 )
139171
140172 return blocking_job , non_blocking_job
141173
174+
142175def _prepare_upload_job (mp , mc , project_path , local_version , changes ):
143176 mp .log .debug ("push changes:\n " + pprint .pformat (changes ))
144177
@@ -226,6 +259,7 @@ def _prepare_upload_job(mp, mc, project_path, local_version, changes):
226259 job .futures .append (future )
227260 return job
228261
262+
229263def push_project_wait (job ):
230264 """blocks until all upload tasks are finished"""
231265
@@ -351,25 +385,3 @@ def remove_diff_files(job) -> None:
351385 if os .path .exists (diff_file ):
352386 os .remove (diff_file )
353387
354-
355- def split_changes (changes ):
356- """Split changes into blocking and non-blocking.
357-
358- Blocking criteria:
359- - any updated files
360- - any removed files
361- - added files that are .gpkg or .qgz (.ggs)
362- """
363- blocking = non_blocking = {"added" : [], "updated" : [], "removed" : [], "renamed" : []}
364-
365- blocking ["updated" ] = changes ["updated" ]
366- blocking ["removed" ] = changes ["removed" ]
367- blocking ["renamed" ] = changes ["renamed" ]
368-
369- for f in changes ["added" ]:
370- if is_qgis_file (f ["path" ]) or is_versioned_file (f ["path" ]):
371- blocking ["added" ].append (f )
372- else :
373- non_blocking ["added" ].append (f )
374-
375- return blocking , non_blocking
0 commit comments