-
Notifications
You must be signed in to change notification settings - Fork 258
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
RF/ENH: remove file prior writing in to_filename #466
base: master
Are you sure you want to change the base?
Conversation
Current coverage is 94.21% (diff: 63.63%)@@ master #466 diff @@
==========================================
Files 160 160
Lines 21197 21207 +10
Methods 0 0
Messages 0 0
Branches 2266 2269 +3
==========================================
+ Hits 19975 19981 +6
- Misses 802 804 +2
- Partials 420 422 +2
|
…_BEFORE_TO_FILENAME env var
429c932
to
cf564b6
Compare
# Remove previous file where new file would be saved | ||
# Necessary e.g. for cases where file is a symlink pointing | ||
# to some non-writable file (e.g. under git annex control) | ||
os.unlink(fh.filename) | ||
self.to_file_map() |
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.
or @matthew-brett do you think it would remain kosher to shift this functionality even deeper into to_file_map? ;)
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.
Yes, to do this properly would mean going down into to_file_map
, because it's possible to save images with filenames that way, but then, at the moment, you'd have to go into the implementation for each file type (to_file_map
not implemented by default).
This change makes me very nervous. For example:
Now consider:
This will give a different result after |
if by 'different result' you mean that file no longer would be a symlink, that would be the feature not a bug if explicitly requested (env var) or it was a git annex path... the only possible usecase I see which this would violate in case of git-annex is that may someone would want to rely on the fact that files are under annex and locked (i.e. can't be modified), and does expect script to fail in such a case. So may be it shouldn't have annex specific handling after all, but imho env variable (or if there was a centralized configuration setting), should be ok, since asks for such behaviour explicitly |
No, I meant that - when the environment variable is not set, the code above will give you the original contents of |
ah, that way. yeah, sure... somewhat by design ;) |
Right - I realize it is by design, but consider this code, where
Now I have to work out if Before your change, the answer depends only on whether Now the answer depends on whether |
You are writing/reading two different files. Result depends on either first I've is a symlink or not anyways. I could argue that with proposed modification logic would be more straightforward - writing to one Durant change the other (by design) On August 6, 2016 9:25:26 PM EDT, Matthew Brett [email protected] wrote:
|
If I understand right, git-annex is the biggest (only?) motivation for this change? Does git-annex symlink to files in the repository? That seems like it would cause chaos for many operations. As you said already, this:
will replace the contents of |
☔ The latest upstream changes (presumably #479) made this pull request unmergeable. Please resolve the merge conflicts. |
Omg, nibotmi buildbot talks to us now? How cute! Or it was a human? |
A bot - but maybe a bot that just passed the Turing test ... |
Closes #465
TODOs
Disclaimer: I am still not sure if that is the most kosher behavior. PR is primarily to test the idea, e.g. if it breaks any tests.
May be such behaviour could be controlled/enabled by some configuration/environment setting (e.g.
NIBABEL_REMOVE_BEFORE_WRITE=1
) so in those cases when it is clearly necessary we could at least easily enable it.