Skip to main content

guard_remove

Function guard_remove 

Source
pub fn guard_remove(path: &Path, expect_ours: bool) -> Result<(), Refuse>
Expand description

May we remove the hook at path?

expect_ours is what separates uninstall (which removes only files carrying our marker) from a caller that has already established ownership some other way. With it set, anything that is not HookFile::Ours is refused with its reason — including a symlink that points AT one of our shims, because deleting the link and deleting the shim are different acts and only one of them was asked for.

HookFile::Absent is Ok: there is nothing to remove and nothing to refuse, and uninstall run twice must not be an error.

The tracked guard applies here exactly as it does to writes, and for a sharper reason: remove_file on a tracked path deletes work.