api for rescanning multiple volumes;

`?scan=/foo,/bar` will perform a filesystem reindexing of volumes
`/foo` and `/bar` even if they only have `e2d` and not `e2ds`
This commit is contained in:
ed 2025-07-07 09:53:03 +00:00
parent 1b2d39857b
commit 42c199e78e
3 changed files with 15 additions and 6 deletions

View file

@ -1501,7 +1501,6 @@ the same arguments can be set as volflags, in addition to `d2d`, `d2ds`, `d2t`,
note: note:
* upload-times can be displayed in the file listing by enabling the `.up_at` metadata key, either globally with `-e2d -mte +.up_at` or per-volume with volflags `e2d,mte=+.up_at` (will have a ~17% performance impact on directory listings) * upload-times can be displayed in the file listing by enabling the `.up_at` metadata key, either globally with `-e2d -mte +.up_at` or per-volume with volflags `e2d,mte=+.up_at` (will have a ~17% performance impact on directory listings)
* `e2tsr` is probably always overkill, since `e2ds`/`e2dsa` would pick up any file modifications and `e2ts` would then reindex those, unless there is a new copyparty version with new parsers and the release note says otherwise * `e2tsr` is probably always overkill, since `e2ds`/`e2dsa` would pick up any file modifications and `e2ts` would then reindex those, unless there is a new copyparty version with new parsers and the release note says otherwise
* the rescan button in the admin panel has no effect unless the volume has `-e2ds` or higher
config file example (these options are recommended btw): config file example (these options are recommended btw):

View file

@ -5100,15 +5100,24 @@ class HttpCli(object):
return "" # unhandled / fallthrough return "" # unhandled / fallthrough
def scanvol(self) -> bool: def scanvol(self) -> bool:
if not self.can_admin:
raise Pebkac(403, "'scanvol' not allowed for user " + self.uname)
if self.args.no_rescan: if self.args.no_rescan:
raise Pebkac(403, "the rescan feature is disabled in server config") raise Pebkac(403, "the rescan feature is disabled in server config")
vn, _ = self.asrv.vfs.get(self.vpath, self.uname, True, True) vpaths = self.uparam["scan"].split(",/")
if vpaths == [""]:
vpaths = [self.vpath]
args = [self.asrv.vfs.all_vols, [vn.vpath], False, True] vols = []
for vpath in vpaths:
vn, _ = self.asrv.vfs.get(vpath, self.uname, True, True)
vols.append(vn.vpath)
if self.uname not in vn.axs.uadmin:
self.log("rejected scanning [%s] => [%s];" % (vpath, vn.vpath), 3)
raise Pebkac(403, "'scanvol' not allowed for user " + self.uname)
self.log("trying to rescan %d volumes: %r" % (len(vols), vols))
args = [self.asrv.vfs.all_vols, vols, False, True]
x = self.conn.hsrv.broker.ask("up2k.rescan", *args) x = self.conn.hsrv.broker.ask("up2k.rescan", *args)
err = x.get() err = x.get()

View file

@ -261,6 +261,7 @@ upload modifiers:
|--|--|--| |--|--|--|
| GET | `?reload=cfg` | reload config files and rescan volumes | | GET | `?reload=cfg` | reload config files and rescan volumes |
| GET | `?scan` | initiate a rescan of the volume which provides URL | | GET | `?scan` | initiate a rescan of the volume which provides URL |
| GET | `?scan=/a,/b` | initiate a rescan of volumes `/a` and `/b` |
| GET | `?stack` | show a stacktrace of all threads | | GET | `?stack` | show a stacktrace of all threads |
## general ## general