Logo Search packages:      
Sourcecode: ubuntuone-client version File versions

def ubuntuone::syncdaemon::filesystem_manager::FileSystemManager::moved (   self,

change the metadata of a moved file

Definition at line 435 of file filesystem_manager.py.

00435                                                      :
        """change the metadata of a moved file"""
        path_from = os.path.normpath(path_from)
        path_to = os.path.normpath(path_to)

        # if the move overwrites other file, adjust *that* metadata
        if path_to in self._idx_path:
            mdid = self._idx_path.pop(path_to)
            mdobj = self.fs[mdid]
            if mdobj["node_id"] is not None:
                del self._idx_node_id[(mdobj["share_id"], mdobj["node_id"])]
            del self.fs[mdid]

        # adjust the metadata of "from" file
        mdid = self._idx_path.pop(path_from)
        logger("move_file: mdid=%r path_from=%r path_to=%r",
                                                    mdid, path_from, path_to)
        mdobj = self.fs[mdid]

        self._idx_path[path_to] = mdid

        # change the path, make it relative to the share_id
        relpath = self._share_relative_path(new_share_id, path_to)
        mdobj["path"] = relpath
        mdobj['share_id'] = new_share_id
        mdobj["info"]["last_moved_from"] = path_from
        mdobj["info"]["last_moved_time"] = time.time()
        # we try to stat, if we fail, so what?
        #pylint: disable-msg=W0704
            mdobj["stat"] = os.stat(path_to)  # needed if not the same FS
        except OSError:
            logger("Got an OSError while getting the stat of %r", path_to)
        self.fs[mdid] = mdobj

        if mdobj["is_dir"]:
            # change the path for all the children of that node
            path_from = path_from + os.path.sep
            len_from = len(path_from)
            for path in (x for x in self._idx_path if x.startswith(path_from)):
                newpath = os.path.join(path_to, path[len_from:])

                # change in the index
                mdid = self._idx_path.pop(path)
                self._idx_path[newpath] = mdid

                # and in the object itself
                mdobj = self.fs[mdid]
                relpath = self._share_relative_path(new_share_id, newpath)
                mdobj["path"] = relpath
                self.fs[mdid] = mdobj

    def delete_metadata(self, path):

Generated by  Doxygen 1.6.0   Back to index