Repository navigation
feat: add --cleanup to remove local files - #52
Merged
Merged
Conversation
dive keeps its base image, the packages installed with pkg and the shell history in its state directory, with no way to remove them short of finding the directory and making the read-only Nix store writable. `dive --cleanup` lists what it will remove with sizes, asks for confirmation (--yes skips it, and is required without a terminal), then removes the state directory and a base image directory given outside of it. It refuses to run while a dive session is open, and points to `sudo rm -rf` when files are owned by root. Removes the item from the README roadmap.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the short-term roadmap item "Add a clean-up command to remove local files".
Behavior
$XDG_STATE_HOME/dive, or the build'sCONFIG_STATE_DIR), plus the base image directory when--img-dirpoints outside of it.--yesskips it, and is required when stdin is not a terminal.{rootful,rootless}/pidsbelonging to a live process nameddive*. Stale pid files are ignored, as are reused PIDs of unrelated processes.chmod_dirs).sudo rm -rf <dir>—sudo dive --cleanupwould resolve root's state directory instead.--cleanupconflicts with a container ID or a command;--yeswithout--cleanupis a usage error. That check is explicit, as clap'srequirescounts a flag's default value as present.The logic lives in a new
dive::cleanupmodule (active_sessions,disk_usage,remove_all), with unit tests.Testing
XDG_STATE_HOMEin a scratch dir): nothing to clean, live session (refused), no terminal without--yes(refused), answern(aborted, nothing removed), answery(removed), and the argument combinations.Docs
README: new "Removing local files" section under Usage; the roadmap item is removed.