mergin/merginproject.py
def apply_push_changes(self, changes):
        """
        For geodiff files update basefiles according to changes pushed to server.

        :param changes: metadata for pulled files
        :type changes: dict[str, list[dict]]
        """
        for k, v in changes.items():
            for item in v:
                path = item['path']
                if not self.is_versioned_file(path):
                    continue

                basefile = self.fpath_meta(path)
                if k == 'removed':
                    os.remove(basefile)
                elif k == 'added':
                    self.geodiff.make_copy_sqlite(self.fpath(path), basefile)
                elif k == 'updated':
                    # in case for geopackage cannot be created diff (e.g. forced update with committed changes from wal file)
                    if "diff" not in item:
                        self.log.info("updating basefile (copy) for: " + path)
                        self.geodiff.make_copy_sqlite(self.fpath(path), basefile)
                    else:
                        self.log.info("updating basefile (diff) for: " + path)
                        # better to apply diff to previous basefile to avoid issues with geodiff tmp files
                        changeset = self.fpath_meta(item['diff']['path'])
                        patch_error = self.apply_diffs(basefile, [changeset])
                        if patch_error:
                            # in case of local sync issues it is safier to remove basefile, next time it will be downloaded from server
                            self.log.warning("removing basefile (because of apply diff error) for: " + path)
                            os.remove(basefile)
                else:
                    pass

        For geodiff files update basefiles according to changes pushed to server.

        :param changes: metadata for pulled files
        :type changes: dict[str, list[dict]]
        
For geodiff files update basefiles according to changes pushed to server.
For geodiff files update basefiles according to changes pushed to server .
def apply_push_changes(self, changes):
        for k, v in changes.items():
            for item in v:
                path = item['path']
                if not self.is_versioned_file(path):
                    continue
                basefile = self.fpath_meta(path)
                if k == 'removed':
                    os.remove(basefile)
                elif k == 'added':
                    self.geodiff.make_copy_sqlite(self.fpath(path), basefile)
                elif k == 'updated':
                    if "diff" not in item:
                        self.log.info("updating basefile (copy) for: " + path)
                        self.geodiff.make_copy_sqlite(self.fpath(path), basefile)
                    else:
                        self.log.info("updating basefile (diff) for: " + path)
                        changeset = self.fpath_meta(item['diff']['path'])
                        patch_error = self.apply_diffs(basefile, [changeset])
                        if patch_error:
                            self.log.warning("removing basefile (because of apply diff error) for: " + path)
                            os.remove(basefile)
                else:
                    pass
def apply_push_changes ( self , changes ) : for k , v in changes . items ( ) : for item in v : path = item [ 'path' ] if not self . is_versioned_file ( path ) : continue basefile = self . fpath_meta ( path ) if k == 'removed' : os . remove ( basefile ) elif k == 'added' : self . geodiff . make_copy_sqlite ( self . fpath ( path ) , basefile ) elif k == 'updated' : if "diff" not in item : self . log . info ( "updating basefile (copy) for: " + path ) self . geodiff . make_copy_sqlite ( self . fpath ( path ) , basefile ) else : self . log . info ( "updating basefile (diff) for: " + path ) changeset = self . fpath_meta ( item [ 'diff' ] [ 'path' ] ) patch_error = self . apply_diffs ( basefile , [ changeset ] ) if patch_error : self . log . warning ( "removing basefile (because of apply diff error) for: " + path ) os . remove ( basefile ) else : pass
For geodiff files update basefiles according to changes pushed to server.
For geodiff files update basefiles according to changes pushed to server .
"""
        For geodiff files update basefiles according to changes pushed to server.

        :param changes: metadata for pulled files
        :type changes: dict[str, list[dict]]
        """ # in case for geopackage cannot be created diff (e.g. forced update with committed changes from wal file) # better to apply diff to previous basefile to avoid issues with geodiff tmp files # in case of local sync issues it is safier to remove basefile, next time it will be downloaded from server
self
changes
metadata for pulled files
metadata for pulled files