Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ncm-dirperm: support for deleting a file/dir #1680

Open
aka7 opened this issue Apr 29, 2024 · 2 comments
Open

ncm-dirperm: support for deleting a file/dir #1680

aka7 opened this issue Apr 29, 2024 · 2 comments

Comments

@aka7
Copy link
Contributor

aka7 commented Apr 29, 2024

not sure if any component provide this, but I would like to control deletion of a file using ncm. so if a give path exists in the system it should remove it.

So, it would be neat if ncm-dirperm can provide this support, so have a option in the line of

ensure: string = "present" with match (SELF, '^(absent|present)$')

if set to absent, it should remove the file if it exists.
if directory, then remove dir recursively?

@ned21
Copy link
Contributor

ned21 commented Apr 30, 2024

I think you could extend the existing type field (which presently accepts f or d) to also have an 'a' option standing for 'absent'. Unfortunately some of the other fields, e.g. owner and perms, are mandatory and would be confusing in this context.

There are a number of issues with dirperm/symlink such as the handling of duplicates (last one added to list wins) and more crucially, what happens if you add a file /foo/bar/baz and then later add an entry for /foo, as well as potential conflicts between dirperm and symlink. There was an idea to merge both of these into a new component, ncm-path, that would handle these by processing all paths in a shortest to longest order, erroring on duplicates and could then also be extended to handle file absence. Unfortunately I don't think we even got as far as agreeing a schema that cover so many use cases! :(

@jrha
Copy link
Member

jrha commented May 2, 2024

We have discussed having "this path must not exist" functionality before, I'm very much for it. Ideally it would in the new ncm-path, but pragmatically it could be added to dirperm with all the above caveats @ned21 highlighted.

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

No branches or pull requests

3 participants