Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions core/services/pcloud/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ log = { workspace = true }
opendal-core = { path = "../../core", version = "0.57.0", default-features = false }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
sha1 = "0.10.6"

[dev-dependencies]
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
68 changes: 44 additions & 24 deletions core/services/pcloud/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,39 +135,42 @@ impl Builder for PcloudBuilder {
.with_context("service", PCLOUD_SCHEME)),
}?;

Ok(PcloudBackend {
core: Arc::new(PcloudCore {
info: {
let am = AccessorInfo::default();
am.set_scheme(PCLOUD_SCHEME)
.set_root(&root)
.set_native_capability(Capability {
stat: true,
let info = {
let am = AccessorInfo::default();
am.set_scheme(PCLOUD_SCHEME)
.set_root(&root)
.set_native_capability(Capability {
stat: true,

create_dir: true,

create_dir: true,
read: true,

read: true,
write: true,

write: true,
delete: true,
rename: true,
copy: true,

delete: true,
rename: true,
copy: true,
list: true,
list_with_recursive: true,

list: true,
shared: true,

shared: true,
..Default::default()
});

..Default::default()
});
am.into()
};

am.into()
},
Ok(PcloudBackend {
core: Arc::new(PcloudCore::new(
info,
root,
endpoint: self.config.endpoint.clone(),
self.config.endpoint.clone(),
username,
password,
}),
)),
})
}
}
Expand Down Expand Up @@ -213,6 +216,9 @@ impl Access for PcloudBackend {
}

if let Some(md) = resp.metadata {
if let Some(file_id) = md.fileid {
self.core.cache_file_id(path, file_id);
}
let md = parse_stat_metadata(md);
return md.map(RpStat::new);
}
Expand Down Expand Up @@ -258,8 +264,8 @@ impl Access for PcloudBackend {
))
}

async fn list(&self, path: &str, _args: OpList) -> Result<(RpList, Self::Lister)> {
let l = PcloudLister::new(self.core.clone(), path);
async fn list(&self, path: &str, args: OpList) -> Result<(RpList, Self::Lister)> {
let l = PcloudLister::new(self.core.clone(), path, args.recursive());
Ok((RpList::default(), oio::PageLister::new(l)))
}

Expand Down Expand Up @@ -293,6 +299,12 @@ impl Access for PcloudBackend {
return Err(Error::new(ErrorKind::Unexpected, format!("{resp:?}")));
}

if from.ends_with('/') {
self.core.invalidate_path_prefix_cache(to);
} else {
self.core.invalidate_path_cache(to);
}

Ok((RpCopy::default(), ()))
}
_ => Err(parse_error(resp)),
Expand Down Expand Up @@ -323,6 +335,14 @@ impl Access for PcloudBackend {
return Err(Error::new(ErrorKind::Unexpected, format!("{resp:?}")));
}

if from.ends_with('/') {
self.core.invalidate_path_prefix_cache(from);
self.core.invalidate_path_prefix_cache(to);
} else {
self.core.invalidate_path_cache(from);
self.core.invalidate_path_cache(to);
}

Ok(RpRename::default())
}
_ => Err(parse_error(resp)),
Expand Down
Loading
Loading