def mkdir(self, path, mode): relpath = self._relpath(path) folder_name = os.path.basename(relpath) os.mkdir(path, mode) self.dht[relpath] = utils.path_stat(path) # update ls of parent dirname = os.path.dirname(relpath) par = self.dht[dirname] utils.rdict_update(par, {'ls':[folder_name]}) self.dht[dirname] = par
def __init__(self, root, bootstrap_node, local_ip='localhost', local_port=8000): self.realroot = realpath(root) self.rwlock = Lock() self.dht = DHT(bootstrap_node, local_ip, local_port) time.sleep(3) # walk dir and update dht files = utils.rgetdir(self.realroot) for path, newval in files.iteritems(): newold = self.dht[path] if newold: utils.rdict_update(newold, newval) self.dht[path] = newold else: self.dht[path] = newval print "done mounting"