-
Notifications
You must be signed in to change notification settings - Fork 102
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
While walking, InverseTransform is invoked for directories - is this a bug? #76
Comments
My intuition is that the bug is in the example, not the code. WDYT? |
Perhaps I'm missing something, but as it stands I think I stand by my initial intuition. I'll attempt to elaborate in hopes that this clarifies my interpretation of functionality. Here is an example program:
Here is the output:
By my understanding, the Another way of looking at it is that it seems throughout the code that there is an intended invariant that directories on the underlying disk never represent an actual key in the store, and I think that invariant implies that the |
Okay, I see what you mean. I think the underlying problem here is an error in the original API design, and that design error's interactions with the code in the repo and the example in the README. One aspect/view on that design error is that anything in diskv uses panic to express error conditions, which is 100% wrong, and 100% my mistake. Another way to describe it would be that the various funcs, including InverseTransform, don't return errors. They should. Or, at least, their return values should be able to express an "invalid" state. I agree that your proposed change would be an improvement. I would also like to see the example in the README updated to not panic. I'm not sure if that would require a change to the function signature. |
Hey @peterbourgon - loving this library and thank you for your stewardship!
Would love to have you take a look at the following lines:
diskv/diskv.go
Lines 597 to 601 in 2566386
By my reading, it would be preferable not to call
InverseTransform
for directories. In my case, I'm using theAdvancedTransform
and its inverse in the README, and this is tickling the "panic" line because directories do not carry the expected extension.What about switching the logic to this? In other words, pass on the directory BEFORE calling
InverseTransform
.The text was updated successfully, but these errors were encountered: