clj-commons / clj-commons/fs

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

Open
#5 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Clojure
Stars
81
Forks
9
PR merge metrics
No merged PRs in 30d

Description

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:

```clojure
(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.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading the fs/copy entry point and trace how copied files are created. Clarify which permission flags should be preserved by default, including the executable, writable, and readable cases shown in the workaround, then verify that copying retains those flags without breaking existing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
clojure
Domain
operating-systems
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.