-
-
Notifications
You must be signed in to change notification settings - Fork 317
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
.hledger.journal file overwritten on -f path typo #1056
Comments
Wow, thanks for the report. Would you be interested in debugging further ? Help available in http://irc.hledger.org. |
On IRC, we determined the issue is the directory ending with a period '.', windows ignores it, but hledger does not, thus it will report the file does not exists, and proceed to create a new file '.hledger.journal'. However, when creating that file, windows removes the period at the end of the directory name, and thus overwrites the original file. |
👏👏 Windows! When will you learn? |
Ideas for resolution:
|
|
...you're right. I have pushed a fix. It should also be highlighted in docs (somewhere?) for users of older hledger versions. If someone wants to propagate this discussion to the upstream haskell lib, that might be a service to the community. |
I've mentioned this issue & requirement at the end of add's documentation (27c01e8). But I'm not sure this is enough. Is there somewhere else appropriate that users of older hledger might notice ? |
I guess we could do this same path check for all commands (not just add and hledger-web add), which would make it more likely to be noticed before it actually causes trouble. But no.. this would require an up to date hledger version, which doesn't have the problem. |
So mention in next release notes and release announcement I guess. Adding it to the FAQ as well (even though it isn't one) might not hurt. |
Thanks! |
…1056] On MS Windows, trying to add or import or web add to a file whose name ends with a dot could cause data loss, so in 2019 I made this raise an error instead (in Hledger.Read.ensureJournalFileExists). But, the logic was backward, so it did not do the check on Windows. Now it does. Also I have removed mention of this from add's doc; currently it's not documented anywhere. It's obscure, but maybe this is not ideal.
…imonmichael#1056] On MS Windows, trying to add or import or web add to a file whose name ends with a dot could cause data loss, so in 2019 I made this raise an error instead (in Hledger.Read.ensureJournalFileExists). But, the logic was backward, so it did not do the check on Windows. Now it does. Also I have removed mention of this from add's doc; currently it's not documented anywhere. It's obscure, but maybe this is not ideal.
On Windows, the following command will overwrite the file
Documents\.hledger.journal
with an empty file. I sometimes make the typo with extra period in the path and I have to restore from backup. Version tested 1.14.1.The text was updated successfully, but these errors were encountered: