@@ -165,6 +165,9 @@ def inspect_files(self):
165165 for file in files :
166166 if self .ignore_file (file ):
167167 continue
168+ if "gpkg" in file :
169+ do_sqlite_checkpoint (os .path .join (root , file ))
170+
168171 abs_path = os .path .abspath (os .path .join (root , file ))
169172 rel_path = os .path .relpath (abs_path , start = self .dir )
170173 proj_path = '/' .join (rel_path .split (os .path .sep )) # we need posix path
@@ -298,6 +301,12 @@ def get_push_changes(self):
298301 :rtype: dict
299302 """
300303 changes = self .compare_file_sets (self .metadata ['files' ], self .inspect_files ())
304+ # do checkpoint to push changes from wal file to gpkg if new file
305+ for file in changes ['added' ]:
306+ if ".gpkg" in file ["path" ]:
307+ do_sqlite_checkpoint (self .fpath (file ["path" ]))
308+ file ["checksum" ] = generate_checksum (self .fpath (file ["path" ]))
309+
301310 for file in changes ['added' ] + changes ['updated' ]:
302311 file ['chunks' ] = [str (uuid .uuid4 ()) for i in range (math .ceil (file ["size" ] / UPLOAD_CHUNK_SIZE ))]
303312
@@ -332,7 +341,11 @@ def get_push_changes(self):
332341 else :
333342 not_updated .append (file )
334343 except (pygeodiff .GeoDiffLibError , pygeodiff .GeoDiffLibConflictError ) as e :
335- pass # we do force update
344+ # do checkpoint to push changes from wal file to gpkg if create changeset failed
345+ do_sqlite_checkpoint (self .fpath (file ["path" ]))
346+ file ["checksum" ] = generate_checksum (self .fpath (file ["path" ]))
347+ file ["size" ] = os .path .getsize (self .fpath (file ["path" ]))
348+ file ['chunks' ] = [str (uuid .uuid4 ()) for i in range (math .ceil (file ["size" ] / UPLOAD_CHUNK_SIZE ))]
336349
337350 changes ['updated' ] = [f for f in changes ['updated' ] if f not in not_updated ]
338351 return changes
@@ -944,10 +957,6 @@ def _push_changes(self, mp, data, parallel):
944957 with concurrent .futures .ThreadPoolExecutor () as executor :
945958 futures_map = {}
946959 for file in upload_files :
947- # do checkpoint to push changes from wal file to gpkg if there is no diff
948- if "diff" not in file and mp .is_versioned_file (file ["path" ]):
949- do_sqlite_checkpoint (mp .fpath (file ["path" ]))
950- file ["checksum" ] = generate_checksum (mp .fpath (file ["path" ]))
951960 file ['location' ] = mp .fpath_meta (file ['diff' ]['path' ]) if 'diff' in file else mp .fpath (file ['path' ])
952961 future = executor .submit (self ._upload_file , info ["transaction" ], file , parallel )
953962 futures_map [future ] = file
@@ -960,10 +969,6 @@ def _push_changes(self, mp, data, parallel):
960969 raise ClientError ("Timeout error: failed to upload {}" .format (file ))
961970 else :
962971 for file in upload_files :
963- # do checkpoint to push changes from wal file to gpkg if there is no diff
964- if "diff" not in file and mp .is_versioned_file (file ["path" ]):
965- do_sqlite_checkpoint (mp .fpath (file ["path" ]))
966- file ["checksum" ] = generate_checksum (mp .fpath (file ["path" ]))
967972 file ['location' ] = mp .fpath_meta (file ['diff' ]['path' ]) if 'diff' in file else mp .fpath (file ['path' ])
968973 self ._upload_file (info ["transaction" ], file , parallel )
969974
0 commit comments