Skip to content

Treat missing device data dir as success when forgetting a device#12895

Open
mvanhorn wants to merge 1 commit into
Scille:masterfrom
mvanhorn:fix/12807-forget-device-missing-data-dir
Open

Treat missing device data dir as success when forgetting a device#12895
mvanhorn wants to merge 1 commit into
Scille:masterfrom
mvanhorn:fix/12807-forget-device-missing-data-dir

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Jun 4, 2026

Copy link
Copy Markdown

Summary

parsec-cli device forget-local no longer errors with Failed to remove device data: Failed to remove data: No such file or directory (os error 2) when the device has no data directory. remove_device_data now treats ErrorKind::NotFound from remove_dir_all as success, making the cleanup idempotent; any other io error still propagates as before.

Why this matters

#12807 reports the confusing hard error on what is actually a successful forget operation - the device key file is removed correctly, but the follow-up data-dir removal fails. AureliaDolo noted in-thread this affects devices created on old organizations, which never got a per-device data directory. The fix is localized to the storage cleanup helper (libparsec/crates/platform_storage/src/native/cleanup.rs); the CLI command and client wrapper are unchanged.

How to test: parsec-cli device forget-local on a device whose <data_base_dir>/<device_id_hex>/ directory does not exist completes without the error; with the directory present, it is removed exactly as before.

Testing

  • New cleanup_device_data_missing_dir test: forgetting a device whose data dir was never created returns Ok (this fails on master with NotFound)
  • Existing cleanup_device_data still passes (directory present and removed)
  • cargo test -p libparsec_platform_storage --lib --features test-with-testbed cleanup: 3 passed
  • News fragment added: newsfragments/12807.bugfix.rst

Fixes #12807

@mvanhorn mvanhorn requested a review from a team as a code owner June 4, 2026 07:51
@FirelightFlagboy

Copy link
Copy Markdown
Contributor

Hello, thanks for the pull-request.

Did you send us a signed Contributor Assignment Agreement?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CLI] Forget local device display an error message

2 participants