use scandir for volume smoketests during up2k init;

gives much faster startup on filesystems that are extremely slow
(TLNote: android sdcardfs)
This commit is contained in:
ed 2024-01-09 21:47:02 +01:00
parent e8a653ca0c
commit f1358dbaba
2 changed files with 9 additions and 2 deletions

View file

@ -37,6 +37,7 @@ from .util import (
absreal,
atomic_move,
db_ex_chk,
dir_is_empty,
djoin,
fsenc,
gen_filekey,
@ -604,7 +605,7 @@ class Up2k(object):
for vol in vols:
try:
bos.makedirs(vol.realpath) # gonna happen at snap anyways
bos.listdir(vol.realpath)
dir_is_empty(self.log_func, not self.args.no_scandir, vol.realpath)
except:
self.volstate[vol.vpath] = "OFFLINE (cannot access folder)"
self.log("cannot access " + vol.realpath, c=1)
@ -991,7 +992,7 @@ class Up2k(object):
rtop = absreal(top)
n_add = n_rm = 0
try:
if not bos.listdir(rtop):
if dir_is_empty(self.log_func, not self.args.no_scandir, rtop):
t = "volume /%s at [%s] is empty; will not be indexed as this could be due to an offline filesystem"
self.log(t % (vol.vpath, rtop), 6)
return True, False

View file

@ -2363,6 +2363,12 @@ def statdir(
print(t)
def dir_is_empty(logger: "RootLogger", scandir: bool, top: str):
for _ in statdir(logger, scandir, False, top):
return False
return True
def rmdirs(
logger: "RootLogger", scandir: bool, lstat: bool, top: str, depth: int
) -> tuple[list[str], list[str]]: