Adding new flag for optional calculation of Volumes created at the root

This commit is contained in:
Victor Phillips 2026-03-24 10:51:18 -04:00
parent 6a9e6da864
commit 0d5e5adc0e
3 changed files with 18 additions and 2 deletions

View file

@ -1794,6 +1794,7 @@ def add_db_general(ap, hcores):
ap2.add_argument("--no-idx", metavar="PTN", type=u, default=noidx, help="regex: disable indexing of matching absolute-filesystem-paths during e2ds folder scan (must be specified as one big regex, not multiple times) (volflag=noidx)")
ap2.add_argument("--no-dirsz", action="store_true", help="do not show total recursive size of folders in listings, show inode size instead; slightly faster (volflag=nodirsz)")
ap2.add_argument("--re-dirsz", action="store_true", help="if the directory-sizes in the UI are bonkers, use this along with \033[33m-e2dsa\033[0m to rebuild the index from scratch")
ap2.add_argument("--deep-dirsz", action="store_true", help="show correct sizes for child volumes in parent listings (possible drain on performance)")
ap2.add_argument("--no-dhash", action="store_true", help="disable rescan acceleration; do full database integrity check -- makes the db ~5%% smaller and bootup/rescans 3~10x slower")
ap2.add_argument("--re-dhash", action="store_true", help="force a cache rebuild on startup; enable this once if it gets out of sync (should never be necessary)")
ap2.add_argument("--no-forget", action="store_true", help="never forget indexed files, even when deleted from disk -- makes it impossible to ever upload the same file twice -- only useful for offloading uploads to a cloud service or something (volflag=noforget)")

View file

@ -7375,6 +7375,14 @@ class HttpCli(object):
for fe in dirs:
try:
hit = icur.execute(q, (vdir + fe["name"],)).fetchone()
if not hit and self.args.deep_dirsz:
child_rp = os.path.join(abspath, fe["name"])
hit = self.conn.hsrv.broker.ask(
"up2k.get_volrootsize", child_rp
).get()
if hit == (0, 0):
hit = None
if hit:
(fe["sz"], fe["tags"][".files"]) = hit
except:
pass # 404 or mojibake

View file

@ -528,6 +528,13 @@ class Up2k(object):
return (nbytes, nfiles)
def get_volrootsize(self, realpath: str) -> tuple[int, int]:
cur = self.cur.get(realpath)
if not cur:
return (0, 0)
hit = cur.execute("select sz, nf from ds where rd='' limit 1").fetchone()
return hit if hit else (0, 0)
def rescan(
self, all_vols: dict[str, VFS], scan_vols: list[str], wait: bool, fscan: bool
) -> str: