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
Fix creating temp directory to support multiple users #178
Conversation
3c22c22
to
a9bba94
Compare
Codecov Report
@@ Coverage Diff @@
## master #178 +/- ##
==========================================
+ Coverage 86.86% 86.92% +0.05%
==========================================
Files 74 74
Lines 5750 5765 +15
Branches 492 490 -2
==========================================
+ Hits 4995 5011 +16
- Misses 263 264 +1
+ Partials 492 490 -2
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for working on this feature! Added a comment about the deletion.
Thanks for the speedy review! I missed out recursive deletions. I've added missing features of recursive deletions, and the tests. |
Sorry for my late push. I fixed miss test's directory a little bit more. |
Sorry, I deleted extra spacing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Looks good other than indentation 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick update! 👍
dir-path (.getPath (file system-tmp-dir-path "cljam"))] | ||
(.mkdirs (file dir-path)) | ||
dir-path)) | ||
(defmacro with-temp-dir |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The expanded form of this macro looks somewhat large. More importantly, it contains a reify
form in it, which would redundantly generate a dedicated anonymous class for each macro callsite.
How about breaking the implementation down into some functions like create-temp-dir
and delete-temp-dir
, and using them in the expanded form?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thanks for another improvement!
Just added a comment on the implementation of the macro.
Thank you for the helpful suggestion! I didn't know that. |
Ah, sorry if I confused you 🙇 I think providing (defmacro with-temp-dir [bindings & body]
(cond ...
(symbol? (bindings 0))
(let [[dir prefix] bindings]
`(let [~dir (create-temp-dir ~prefix)]
(try
(with-temp-dir ~(subvec bindings 2) ~@body)
(finally
(delete-temp-dir! ~dir)))))
...)) |
4820564
to
28fb728
Compare
Thank you for reviewing and I apologize for my poor understanding. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍I will merge it, thanks!
Thank you for correcting me and merging! |
In the current implementation of creating temporary user's directory, there are two problems: always creates the directory of the same name
cljam
, and doesn't delete it after all is done. That might causePermission denied
if multiple users run cljam on the same machine.This PR fixes the behavior;
with-temp-dir
macro creates an unique directory, and finally deletes it. Also, fixes a path to temporary directory such that the test code creates user's directory instead of test's directory.