def symlink(self, dest, symlink, uid=None, gid=None, document=None): ''' Call type : "Create" ''' updated = [] # Firstly make the symlink on the filesystem self.realfs.symlink(dest, symlink) stats = MutableStat(self.realfs.lstat(symlink)) if uid: stats.st_uid = uid if gid: stats.st_gid = gid if not document: # Then create the document into the database fields = { 'filename' : posixpath.basename(symlink), 'dirpath' : posixpath.dirname(symlink), 'mode' : 0777 | stat.S_IFLNK, 'type' : "application/x-symlink", 'stats' : stats } updated.append(self.doc_helper.create(**fields)) else: document._data['_id'] = document.id self.doc_helper.database.save(document._data) updated.append(document) # Finally update the stats of the parent directory into the database parent = self[posixpath.dirname(symlink)] parent.set_stats(self.realfs.lstat(os.path.dirname(symlink))) updated.extend(self.doc_helper.update(parent)) return updated
@normpath def mkdir(self, path, mode=0700, uid=None, gid=None, document=None): ''' Call type : "Create" ''' # TODO: test if couchdb is responding before apply changes on fs updated = [] # Firstly make the directory on the filesystem self.realfs.mkdir(path, mode) # Then create the document into the database if not document: stats = MutableStat(self.realfs.lstat(path)) stats.st_uid = uid stats.st_gid = gid fields = { 'filename' : posixpath.basename(path), 'dirpath' : posixpath.dirname(path), 'mode' : mode | stat.S_IFDIR, 'type' : "application/x-directory", 'stats' : stats } updated.append(self.doc_helper.create(**fields)) else: stats = document.stats document._data['_id'] = document.id self.doc_helper.database.save(document._data) updated.append(document)