Commit e36c68e
committed
feat(api): add virtual_path field on fs/list and fs/get responses
The existing `path` field on ObjResp/ObjLabelResp returns whatever the
storage driver writes into model.Object.Path, and that contract has
quietly diverged across drivers:
- Local sets it to the physical disk path
(e.g. `/data/data/com.termux/files/home/storage/download/foo.tar.gz`)
- Cloud drivers (Quark / Baidu / 115 / …) leave it empty
- Some other drivers fill it with their own internal id-like path
Clients that need the canonical alist virtual path (e.g. for `share`,
`fs/copy`, navigation) cannot rely on `path` alone. The frontend has
been working around this with branchy code such as
`pathJoin(getCurrentPath(), name)` in some places and
`obj.path` in others; one such mismatch caused a share regression on
Local mounts whose root_folder_path differs from the mount path
(visible as `failed get storage: storage not found; rawPath: ...`).
Add a `virtual_path` field that is always the alist virtual path for
the object:
- `toObjsResp` -> `FixAndCleanPath(stdpath.Join(parent, obj.Name))`
- `FsGet` -> `FixAndCleanPath(reqPath)`
`path` is left untouched for backwards compatibility. Clients should
prefer `virtual_path` for anything that talks to other alist APIs.1 parent f4445c5 commit e36c68e
1 file changed
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
| 69 | + | |
68 | 70 | | |
69 | 71 | | |
70 | 72 | | |
| |||
318 | 320 | | |
319 | 321 | | |
320 | 322 | | |
| 323 | + | |
321 | 324 | | |
322 | 325 | | |
323 | 326 | | |
| |||
452 | 455 | | |
453 | 456 | | |
454 | 457 | | |
| 458 | + | |
455 | 459 | | |
456 | 460 | | |
457 | 461 | | |
| |||
0 commit comments