Exemple #1
0
    def current_hash(self, path):
        """Return the hash of the file as it exists now in the filesystem"""

        fullpath = join(self.syncdir, path)
        if fullpath in self.deleted_dirs:
            return 'DEL'
        if not exists(fullpath):
            return 'DEL'
        if isdir(fullpath):
            return 'DIR'
        return merkle(fullpath)
Exemple #2
0
    def current_hash(self, path):
        """Return the hash of the file as it exists now in the filesystem"""

        fullpath = join(self.syncdir, path)
        if fullpath in self.deleted_dirs:
            return 'DEL'
        if not exists(fullpath):
            return 'DEL'
        if isdir(fullpath):
            return 'DIR'
        return merkle(fullpath)
Exemple #3
0
    def trash(self, path):
        """Move a file to trash or delete it if it's a directory"""

        fullpath = join(self.syncdir, path)
        if not exists(fullpath):
            return

        if isfile(fullpath):
            hash = merkle(fullpath)
            trashpath = join(self.trashdir, hash)
            os.rename(fullpath, trashpath)
        else:
            self.rmdir(path)
Exemple #4
0
    def trash(self, path):
        """Move a file to trash or delete it if it's a directory"""

        fullpath = join(self.syncdir, path)
        if not exists(fullpath):
            return

        if isfile(fullpath):
            hash = merkle(fullpath)
            trashpath = join(self.trashdir, hash)
            os.rename(fullpath, trashpath)
        else:
            self.rmdir(path)