features-42
deadc0de6 4 months ago
parent ac4ba145fe
commit 1c74290fa1

@ -198,7 +198,7 @@ class Noder:
return top return top
def new_file_node(self, name: str, path: str, def new_file_node(self, name: str, path: str,
parent: NodeAny, storagepath: str) -> Optional[NodeFile]: parent: NodeAny) -> Optional[NodeFile]:
"""create a new node representing a file""" """create a new node representing a file"""
if not os.path.exists(path): if not os.path.exists(path):
Logger.err(f'File \"{path}\" does not exist') Logger.err(f'File \"{path}\" does not exist')
@ -230,7 +230,7 @@ class Noder:
return node return node
def new_dir_node(self, name: str, path: str, def new_dir_node(self, name: str, path: str,
parent: NodeAny, storagepath: str) -> NodeDir: parent: NodeAny) -> NodeDir:
"""create a new node representing a directory""" """create a new node representing a directory"""
path = os.path.abspath(path) path = os.path.abspath(path)
maccess = os.path.getmtime(path) maccess = os.path.getmtime(path)

@ -47,8 +47,9 @@ class Walker:
""" """
self._debug(f'indexing starting at {path}') self._debug(f'indexing starting at {path}')
if not parent: if not parent:
parent = self.noder.new_dir_node(name, path, parent = self.noder.new_dir_node(name,
parent, storagepath) path,
parent)
if os.path.islink(path): if os.path.islink(path):
rel = os.readlink(path) rel = os.readlink(path)
@ -65,8 +66,9 @@ class Walker:
continue continue
self._progress(file) self._progress(file)
self._debug(f'index file {sub}') self._debug(f'index file {sub}')
node = self.noder.new_file_node(os.path.basename(file), sub, node = self.noder.new_file_node(os.path.basename(file),
parent, storagepath) sub,
parent)
if node: if node:
cnt += 1 cnt += 1
for adir in dirs: for adir in dirs:
@ -76,7 +78,7 @@ class Walker:
self._debug(f'index directory {sub}') self._debug(f'index directory {sub}')
if not os.path.exists(sub): if not os.path.exists(sub):
continue continue
dummy = self.noder.new_dir_node(base, sub, parent, storagepath) dummy = self.noder.new_dir_node(base, sub, parent)
if not dummy: if not dummy:
continue continue
cnt += 1 cnt += 1
@ -118,8 +120,9 @@ class Walker:
if node: if node:
node.flag() node.flag()
continue continue
node = self.noder.new_file_node(os.path.basename(file), sub, node = self.noder.new_file_node(os.path.basename(file),
parent, storagepath) sub,
parent)
if node: if node:
node.flag() node.flag()
cnt += 1 cnt += 1
@ -131,7 +134,7 @@ class Walker:
reindex, dummy = self._need_reindex(parent, sub, treepath) reindex, dummy = self._need_reindex(parent, sub, treepath)
if reindex: if reindex:
dummy = self.noder.new_dir_node(base, sub, dummy = self.noder.new_dir_node(base, sub,
parent, storagepath) parent)
cnt += 1 cnt += 1
if dummy: if dummy:
dummy.flag() dummy.flag()

Loading…
Cancel
Save