Skip to content

Commit 42c199e

Browse files
committed
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`
1 parent 1b2d398 commit 42c199e

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1501,7 +1501,6 @@ the same arguments can be set as volflags, in addition to `d2d`, `d2ds`, `d2t`,
15011501
note:
15021502
* 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)
15031503
* `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
1504-
* the rescan button in the admin panel has no effect unless the volume has `-e2ds` or higher
15051504
15061505
config file example (these options are recommended btw):
15071506

copyparty/httpcli.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5100,15 +5100,24 @@ def on40x(self, mods: list[str], vn: VFS, rem: str) -> str:
51005100
return "" # unhandled / fallthrough
51015101

51025102
def scanvol(self) -> bool:
5103-
if not self.can_admin:
5104-
raise Pebkac(403, "'scanvol' not allowed for user " + self.uname)
5105-
51065103
if self.args.no_rescan:
51075104
raise Pebkac(403, "the rescan feature is disabled in server config")
51085105

5109-
vn, _ = self.asrv.vfs.get(self.vpath, self.uname, True, True)
5106+
vpaths = self.uparam["scan"].split(",/")
5107+
if vpaths == [""]:
5108+
vpaths = [self.vpath]
5109+
5110+
vols = []
5111+
for vpath in vpaths:
5112+
vn, _ = self.asrv.vfs.get(vpath, self.uname, True, True)
5113+
vols.append(vn.vpath)
5114+
if self.uname not in vn.axs.uadmin:
5115+
self.log("rejected scanning [%s] => [%s];" % (vpath, vn.vpath), 3)
5116+
raise Pebkac(403, "'scanvol' not allowed for user " + self.uname)
5117+
5118+
self.log("trying to rescan %d volumes: %r" % (len(vols), vols))
51105119

5111-
args = [self.asrv.vfs.all_vols, [vn.vpath], False, True]
5120+
args = [self.asrv.vfs.all_vols, vols, False, True]
51125121

51135122
x = self.conn.hsrv.broker.ask("up2k.rescan", *args)
51145123
err = x.get()

docs/devnotes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ upload modifiers:
261261
|--|--|--|
262262
| GET | `?reload=cfg` | reload config files and rescan volumes |
263263
| GET | `?scan` | initiate a rescan of the volume which provides URL |
264+
| GET | `?scan=/a,/b` | initiate a rescan of volumes `/a` and `/b` |
264265
| GET | `?stack` | show a stacktrace of all threads |
265266

266267
## general

0 commit comments

Comments
 (0)