Add service selection to hydrus file wrapper operations

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/15/head
trivernis 2 years ago
parent 6b06a9cf60
commit 715fb9f5f2
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -239,12 +239,32 @@ impl HydrusFile {
DeleteFilesBuilder::new(self.client.clone()).add_file(self.id.clone())
}
/// Undeletes the file
pub async fn undelete(&mut self) -> Result<()> {
/// Undeletes the file for the given service or all services
/// if `FileServiceSelection::none` is passed
pub async fn undelete(&mut self, service_selection: FileServiceSelection) -> Result<()> {
let hash = self.hash().await?;
self.metadata = None;
self.client
.undelete_files(FileSelection::by_hash(hash), FileServiceSelection::none())
.undelete_files(FileSelection::by_hash(hash), service_selection)
.await
}
/// Archives the file in all passed file services or all configured services
/// if no selection is passed
pub async fn archive(&mut self, service_selection: FileServiceSelection) -> Result<()> {
let hash = self.hash().await?;
self.metadata = None;
self.client
.archive_files(FileSelection::by_hash(hash), service_selection)
.await
}
/// Unarchives the file for the given services
pub async fn unarchive(&mut self, service_selection: FileServiceSelection) -> Result<()> {
let hash = self.hash().await?;
self.metadata = None;
self.client
.unarchive_files(FileSelection::by_hash(hash), service_selection)
.await
}

@ -117,9 +117,8 @@ async fn it_deletes() {
let mut file = get_file().await;
file.delete()
.reason("I just don't like that file")
.service(ServiceName::all_local_files().into())
.run()
.await
.unwrap();
file.undelete().await.unwrap();
file.undelete(ServiceName::my_files().into()).await.unwrap();
}

Loading…
Cancel
Save