Skip to content

Conversation

@amustaque97
Copy link

This pull request replaces the legacy Bash script for cleaning unused build and target directories on dev-desktop systems with a new Rust implementation (clean-unused-checkouts). The Rust binary is now built in the setup-deploy-keys crate and distributed to target systems via Ansible. The Bash script has been removed from the repository.


- name: Install clean-unused-checkouts binary
copy:
src: "{{ playbook_dir }}/../../../../setup-deploy-keys/target/release/clean-unused-checkouts"
Copy link

@Carbonhell Carbonhell Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(disclaimer: I don't know much of Ansible) is the intended deployment strategy to compile the binary locally, with the target set based on the dev-desktop architecture/os? Would it make sense to add the compilation step as an Ansible task/playbook? Otherwise a simple note in the README would work as well

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me neither. Let's wait for the review from the team, and I will make the necessary changes.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could make sense to rename the parent folder from setup-deploy-keys to something more generic, such as cli-utilities or similar, if the idea is to have multiple simple CLI tools inside this folder

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree 💯 . I like to break this task into 2 separate PRs, once this PR is approved and merged. I can raise the next PR to rename the directory. WDYT?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah depends on what the infra team prefers - either renaming the folder to use it for multiple scripts, or making a separate folder for each script

let mut result = Vec::new();
for entry in fs::read_dir(home)? {
let entry = entry?;
let path = entry.path();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this implementation handle symlinks? This might be extreme, but I assume that users of dev-desktops could accidentally / intentionally create a symlink loop which might cause an infinite loop here. Since you already define walkdir as a dependency, perhaps it could be used here as well for the recursive search of project dirs (by default, it does not follow symlinks). The original issue has a snippet that could be used here I think (see find_artifact_directories definition)

Copy link
Author

@amustaque97 amustaque97 Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, thanks for the idea. I have made the changes to prevent a symlink loop.

}

#[cfg(test)]
mod tests {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth adding a specific test for find_cache_dirs and print_or_delete, as the former controls what will be scheduled for deletion, whereas the latter controls what actually gets deleted, to ensure no accidental changes end up scheduling wrong folders for deletion

Copy link

@Carbonhell Carbonhell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok to me!

}

result.sort();
result.dedup();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: since we don't want duplicates and we don't care about ordering, we could use a hashset instead of a vec

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.

2 participants