Address trash moves and deletes by path, not fileid
Trashing or emptying the trash failed on every scanned image with "operation unsupported by this backend: fetch by fileid requires a path". RemoteId::Stable(oc:fileid) is an identity — it answers whether a file is the same one after a move, and keys the thumbnail shards. It is not an address: WebDAV exposes no fileid-addressable endpoint, so the Nextcloud backend serves get/delete/move_to by path and rejects a bare Stable. Both trash workers preferred the fileid whenever the catalog knew one, so the unreachable Path fallback was the only arm that would have worked, and the failure hit every properly-scanned image rather than some edge case. Address by path at both sites, and keep the fileid for what it is for: the identity MOVE preserves, and the key the thumbnail cleanup uses. Move::file_id was documented as "the id the MOVE addresses", which is the wrong claim that seeded this; corrected, along with a note on RemoteId itself so the distinction is stated where the type is defined. Only the backend rejection was covered by a test. Added the positive case, since that contract is what the call sites now depend on. The workers build their own NextcloudBackend, so no test can reach the call sites directly — closing that would mean injecting the backend, which is left alone here. Verified by build and test; not exercised against a live server. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -530,6 +530,20 @@ mod tests {
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn addressing_by_path_is_what_works() {
|
||||
// The counterpart to the rejection above, and the reason trash and
|
||||
// purge pass `RemoteId::Path` even when the catalog knows the fileid:
|
||||
// every id-taking method routes through here, so a `Stable` turns a
|
||||
// trash into "operation unsupported by this backend".
|
||||
let b = backend();
|
||||
assert_eq!(
|
||||
b.url_for_id(&RemoteId::Path(RemotePath::new("Photos/_MG_8154.dng")))
|
||||
.unwrap(),
|
||||
"https://cloud.example/remote.php/dav/files/duncan/Photos/_MG_8154.dng"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn statuses_map_to_actionable_errors() {
|
||||
use reqwest::StatusCode;
|
||||
|
||||
Reference in New Issue
Block a user