Consider gzip/gunzip to self
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start at the public gzip and gunzip entry points and reproduce the self-targeting examples from the issue. Compare their behavior with copy and move, then inspect any existing tests around file transformation and overwrite handling. Done means the project has an agreed, documented or enforced behavior for gzip/gunzip targeting the source itself.
Written by the indexing model from the issue text.
Description
Scenario
I have noticed that it is technically possible to request a gzip to self:
(require '[babashka.fs :as fs])
(spit "foo.txt" "foo")
(fs/gzip "foo.txt" {:out-file "foo.txt"})
;; => "./foo.txt"
And then to gunzip to self:
(fs/gunzip "foo.txt")
;; => Execution error (FileAlreadyExistsException) at sun.nio.fs.UnixException/translateToIOException (UnixException.java:94).
;; ./foo.txt
(fs/gunzip "foo.txt" "." {:replace-existing true})
;; => 10
But if we then slurp the resulting foo.txt
(slurp "foo.txt")
;; => "�\b\0\0\0\0\0\0�"
We see that it is not the gunzipped file.
Option 0 - Do nothing
Users should know not to do that.
Option 1 - Doc
Add a little note to docstrings that gzip/gunzip to self is not supported
Option 2 - Throw
Throw when attempting to zip/unzip to self
Option 3 - Support Use Case
Actually allow for gzip/gunzip to self.
What do other fns do?
I looked at copy and move.
They are no-ops when copying/moving to self.
But they are different from gzip gunzip which also does a transformation.
So, not applicable.
copy-tree does throw on an attempt to copy under itself.
Proposal
I think Option 3 - support use case - is too obscure to bother with.
My preference is Option 2 - throw.
Explicitly don't allow it.
Help users discover they made a mistake.
But I think Option 1 - doc - is also worth considering.
Whatcha think?
- Dominant language
- Clojure
- Stars
- 221
- Forks
- 52
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from babashka/fs
-
Difficulty 2/5 1-3 hours Newbie friendliness 48/100
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
-
`copy-tree`, when following links, does not copy contents of symbolicly linked sub-dirPossibly taken @shivampwm2020 claimed this 51 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
nextjournal/clerk#830 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
IOP tokens release blocker team qa team qa autotests WG adoption
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
penpot/penpot#13540 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
izhangzhihao/intellij-rainbow-brackets#2903 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100