File tree Expand file tree Collapse file tree 4 files changed +18
-4
lines changed
Expand file tree Collapse file tree 4 files changed +18
-4
lines changed Original file line number Diff line number Diff line change 11// Parsec Cloud (https://parsec.cloud) Copyright (c) BUSL-1.1 2016-present Scille SAS
22
33use libparsec_platform_device_loader:: AvailableDevice ;
4- use libparsec_types :: prelude :: * ;
4+ use libparsec_platform_storage :: RemoveDeviceDataError ;
55
66use crate :: ClientConfig ;
77
@@ -10,7 +10,7 @@ pub enum RemoveDeviceError {
1010 #[ error( "Failed to remove device: {}" , . 0 ) ]
1111 DeviceRemovalError ( libparsec_platform_device_loader:: RemoveDeviceError ) ,
1212 #[ error( "Failed to remove device data: {}" , . 0 ) ]
13- DeviceDataRemovalError ( anyhow :: Error ) ,
13+ DeviceDataRemovalError ( RemoveDeviceDataError ) ,
1414}
1515
1616/// Remove device from existence.
Original file line number Diff line number Diff line change @@ -13,6 +13,13 @@ pub(crate) use web as platform;
1313pub mod certificates;
1414pub mod user;
1515pub mod workspace;
16+
17+ #[ derive( Debug , thiserror:: Error ) ]
18+ pub enum RemoveDeviceDataError {
19+ #[ error( "Failed to remove data: {0}" ) ]
20+ FailedToRemoveData ( #[ from] libparsec_types:: anyhow:: Error ) ,
21+ }
22+
1623pub use platform:: cleanup:: remove_device_data;
1724
1825// Testbed integration is tested in the `libparsec_tests_fixture` crate.
Original file line number Diff line number Diff line change @@ -4,13 +4,17 @@ use std::path::Path;
44
55use libparsec_types:: { anyhow, DeviceID } ;
66
7- pub async fn remove_device_data ( data_base_dir : & Path , device_id : DeviceID ) -> anyhow:: Result < ( ) > {
7+ pub async fn remove_device_data (
8+ data_base_dir : & Path ,
9+ device_id : DeviceID ,
10+ ) -> Result < ( ) , crate :: RemoveDeviceDataError > {
811 let path = data_base_dir. join ( device_id. hex ( ) ) ;
912 log:: debug!( "Removing device data at {}" , path. display( ) ) ;
1013
1114 tokio:: fs:: remove_dir_all ( & path)
1215 . await
1316 . map_err ( anyhow:: Error :: from)
17+ . map_err ( Into :: into)
1418}
1519
1620#[ cfg( test) ]
Original file line number Diff line number Diff line change @@ -14,7 +14,10 @@ async fn drop_db(name: &str) -> anyhow::Result<()> {
1414 . map_err ( anyhow:: Error :: from)
1515}
1616
17- pub async fn remove_device_data ( data_base_dir : & Path , device_id : DeviceID ) -> anyhow:: Result < ( ) > {
17+ pub async fn remove_device_data (
18+ data_base_dir : & Path ,
19+ device_id : DeviceID ,
20+ ) -> Result < ( ) , crate :: RemoveDeviceDataError > {
1821 drop_db ( & get_certificates_storage_db_name ( data_base_dir, device_id) ) . await ?;
1922 drop_db ( & get_user_storage_db_name ( data_base_dir, device_id) ) . await ?;
2023
You can’t perform that action at this time.
0 commit comments