Skip to content

Commit

Permalink
Fix #8601: Remove device data alongside the device
Browse files Browse the repository at this point in the history
  • Loading branch information
FirelightFlagboy committed Oct 3, 2024
1 parent 2d7be1d commit a8ad72a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions 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 cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ testenv = []

[dependencies]
libparsec = { workspace = true }
libparsec_client = { workspace = true }
libparsec_client_connection = { workspace = true }
libparsec_platform_ipc = { workspace = true }

Expand Down
12 changes: 10 additions & 2 deletions cli/src/commands/device/remove.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Parsec Cloud (https://parsec.cloud) Copyright (c) BUSL-1.1 2016-present Scille SAS

use libparsec::AvailableDevice;
use libparsec_client::remove_device;

use crate::utils::*;

Expand All @@ -17,7 +18,14 @@ pub async fn main(args: Args) -> anyhow::Result<()> {
config_dir.display(),
);

let device = load_device_file(&config_dir, device).await?;
// FIXME: https://github.com/Scille/parsec-cloud/issues/8591
// The client config should be loaded from a config file
let config = libparsec_client::ClientConfig::from(libparsec::ClientConfig {
config_dir,
..Default::default()
});

let device = load_device_file(&config.config_dir, device).await?;

let short_id = &device.device_id.hex()[..3];
let AvailableDevice {
Expand All @@ -36,7 +44,7 @@ pub async fn main(args: Args) -> anyhow::Result<()> {

match input.trim() {
"y" => {
std::fs::remove_file(&device.key_file_path)?;
remove_device(&config, &device).await?;
println!("The device has been removed");
}
_ => eprintln!("Operation cancelled"),
Expand Down
1 change: 1 addition & 0 deletions newsfragments/8601.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
On the CLI when removing a device (``device remove``), it will now also remove its associated data (workspaces, certificates, etc).

0 comments on commit a8ad72a

Please sign in to comment.