Ejemplo n.º 1
0
    def pull(self, path, is_new):
        qualifier = 'new ' if is_new else ''
        notify("", "Pulling %sfile from server" % qualifier, path)

        info = self.remote_client.get_state(path)
        if info is None:
            # operation was triggered on deprecated info
            local_info = self.local_client.get_state(path)
            if local_info is None:
                # deleted on both sides, cleanup the metadata record
                self.storage.delete_state(self.binding, path)
            else:
                # content has been deleted: perform a delete instead
                self.delete_local(path)
        else:
            # transfer the content
            if info.type == 'folder':
                self.local_client.mkdir(path)
            else:
                content = self.remote_client.get_content(path)
                if is_new:
                    self.local_client.mkfile(path, content)
                else:
                    self.local_client.update(path, content)

            # update the metadata
            state = self.storage.get_state(self.binding, path)
            state.set_state('local', 'synchronized')
            state.set_state('remote', 'synchronized')
            new_info = self.local_client.get_state(path)
            state.set_info('local', new_info)
            self.storage.set_state(self.binding, state)
Ejemplo n.º 2
0
 def test(self):
     notification.notify("Test", "Title", "Message")
Ejemplo n.º 3
0
 def delete_local(self, path):
     notify("", "Deleting local file", path)
     self.local_client.delete(path)
     self.storage.delete_state(self.binding, path)
Ejemplo n.º 4
0
 def delete_remote(self, path):
     notify("", "Deleting remote file", path)
     self.remote_client.delete(path)
     self.storage.delete_state(self.binding, path)