def list_directory(self, path): """ Create a directory listing of the given directory path """ real_path = self._canonicalize_path(path) if real_path == '/': real_path = '' parent_1, parent_2 = _split_md5(hashlib.md5(real_path).digest()) return self.list_directory_split_md5(parent_1, parent_2)
def backtrace_path_split_md5(self, md5path_1, md5path_2): """ finds the file path associated with a given MD5 hash """ catalog_root_path = self.root_prefix if self.root_prefix != "/" else "" root_md5_hash = _split_md5(hashlib.md5(catalog_root_path).digest()) result = "" while True: res = self.run_sql("SELECT parent_1, parent_2, name \ FROM catalog \ WHERE md5path_1 = " + str(md5path_1) + " \ AND md5path_2 = " + str(md5path_2) + ";") if len(res) != 1: break md5parent_1, md5parent_2 = res[0][0], res[0][1] if md5parent_1 == root_md5_hash[0] and \ md5parent_2 == root_md5_hash[1]: break result = res[0][2] + ("/" + result if result != "" else "") md5path_1 = md5parent_1 md5path_2 = md5parent_2 return self.root_prefix + result if result != "" else None
def find_directory_entry_md5(self, md5path): """ Finds the DirectoryEntry for a given MD5 hashed path """ lo, hi = _split_md5(md5path.digest()) return self.find_directory_entry_split_md5(lo, hi)
def list_directory(self, path): """ Create a directory listing of the given directory path """ real_path = self._canonicalize_path(path) parent_1, parent_2 = _split_md5(hashlib.md5(real_path).digest()) return self.list_directory_split_md5(parent_1, parent_2)