def makeDir(self, path, mode, uid, gid): if self.levels[path.count("/") - 1] != "buddy": View.mkdir(self, path, mode) try: if self.statFile(path): raise OSError(errno.EEXIST, os.strerror(errno.EEXIST)) except OSError, e: if e.errno != errno.ENOENT: raise
def statFile(self, path): if (path.count(os.sep) == 1 and self._fullnameBindings.has_key(os.path.basename(path))): listpath = path.split(os.sep) listpath[1] = self._fullnameBindings[os.path.basename(path)] path = os.sep.join(listpath) return View.statFile(self, path)
def makeDir(self, path, mode, uid, gid): """ Create a tag if path is at 'tag' level. """ if self.isFileLevel(path): View.makeDir(self, path, mode) tag = os.path.basename(path) try: self._syncDocs.by_tag(key=tag, pk=True) raise OSError(errno.EEXIST, os.strerror(errno.EEXIST)) except tsumufs.DocumentException, e: if tag in self._pendingTags: raise OSError(errno.EEXIST, os.strerror(errno.EEXIST)) self._pendingTags.append(tag)
def rename(self, old, new): """ Assign a tag to a file. """ if not self.isFileLevel(new): View.rename(self, old, new) tag = os.path.basename(os.path.dirname(new)) overlaypath = self.overlayPath(old) if tag in tsumufs.fsOverlay[overlaypath].tags: raise OSError(errno.EEXIST, "File already tagged with this tag.") tsumufs.fsOverlay.tag(overlaypath, tag) self._debug('Add "tags" metadata change for %s' % overlaypath) tsumufs.syncLog.addMetadataChange(overlaypath)
def getDirents(self, path): returned = [] for dirent in View.getDirents(self, path): returned.append(dirent.filename) yield dirent if not path.count(os.sep): for friend in self._pendingFriends: if friend['fullname'] not in returned: yield self.docClass(filename=friend['fullname'], mode=0555 | stat.S_IFDIR, uid=friend['uid'], gid=friend['gid']) else: returned.remove(friend['fullname'])
def getDirents(self, path): """ Add to the result of getDirent on the parent call View, and add the pending tags dir to the dirents if path is at 'tag' level. """ returned = [] for dirent in View.getDirents(self, path): yield dirent returned.append(dirent.filename) if not path.count(os.sep): for tag in self._pendingTags: if tag not in returned: yield self.docClass(filename=tag, mode=0555 | stat.S_IFDIR) else: returned.remove(tag)
def __init__(self): self._syncDocs = DocumentHelper(tsumufs.SyncDocument, tsumufs.dbName) View.__init__(self)
def __init__(self): View.__init__(self)