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

I expect copied files to have the same flags as the original file #5

Open
RutledgePaulV opened this issue Oct 19, 2019 · 2 comments
Open

Comments

@RutledgePaulV
Copy link

RutledgePaulV commented Oct 19, 2019

I've been copying some executable files and noticed the permission flags are getting dropped on a copy. It would be nice if the library defaulted to maintaining file flags.

My workaround:

(defn copy-permissions [from to]
  (when (fs/executable? from)
    (fs/chmod "+x" to))
  (when (fs/writeable? from)
    (fs/chmod "+w" to))
  (when (fs/readable? from)
    (fs/chmod "+r" to)))

(defonce _|HACK_TOWN
  (alter-var-root #'fs/copy
    (fn [old]
      (fn [from to]
        (old from to)
        (copy-permissions from to)))))

Happy to turn it into a PR if others are in agreement about the change in functionality.

@slipset
Copy link
Member

slipset commented Dec 30, 2020

Not sure how to proceed with this, as I don't want to change the semantics of this fn. It would be possible to add a second arity which accepted an options map?

@borkdude
Copy link

borkdude commented Dec 30, 2020

I'm working on a modernized version of fs here, which reflects the usage of Java nio:

https://github.com/babashka/fs/blob/9bddc8428f344f21f1c2a306314e7a2222f37205/src/babashka/fs.clj#L143

It takes the following options:

{:keys [:replace-existing
        :copy-attributes
        :nofollow-links
        :recursive]}

which are named after the Java 7 options.

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

No branches or pull requests

3 participants