fix:add,import,web: really avoid filenames ending with . on Windows [#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.
This commit is contained in:
parent
d462611d6a
commit
9ccc1d3fa5
@ -348,7 +348,7 @@ requireJournalFileExists f = do
|
||||
-- which could cause data loss (see 'isWindowsUnsafeDotPath').
|
||||
ensureJournalFileExists :: FilePath -> IO ()
|
||||
ensureJournalFileExists f = do
|
||||
when (os/="mingw32" && isWindowsUnsafeDotPath f) $ do
|
||||
when (os=="mingw32" && isWindowsUnsafeDotPath f) $ do
|
||||
hPutStr stderr $ "Part of file path \"" <> show f <> "\"\n ends with a dot, which is unsafe on Windows; please use a different path.\n"
|
||||
exitFailure
|
||||
exists <- doesFileExist f
|
||||
|
||||
@ -67,7 +67,3 @@ and you have declared a default commodity with a `D` directive,
|
||||
you might expect `add` to add this symbol for you.
|
||||
It does not do this; we assume that if you are using a `D` directive
|
||||
you prefer not to see the commodity symbol repeated on amounts in the journal.
|
||||
|
||||
On Microsoft Windows, the add command makes sure that no part of the
|
||||
file path ends with a period, as that would cause problems
|
||||
([#1056](https://github.com/simonmichael/hledger/issues/1056)).
|
||||
|
||||
Loading…
Reference in New Issue
Block a user