moveFile on windows forgot to delete src file in fallback case

This dates back to commit 625303226d,
where a cross-device moveFile on Windows was made to fall back to copying
to the destination, but forgot to delete the source file.

Should fix the following test suite failure on Windows:

    import:                                FAIL (2.52s)
      .\Test\Framework.hs:383:
      C:\Users\RUNNER~1\AppData\Local\Temp\importtest.0\import1\f exists unexpectedly
      Use -p '/import/' to rerun this test only.

Which was seen here, running the test suite in the github action environment.
https://github.com/psychoinformatics-de/git-annex-wheel/issues/5
This commit is contained in:
Joey Hess 2025-05-30 13:18:26 -04:00
parent 622979432b
commit b111009868
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 5 additions and 1 deletions

View file

@ -65,10 +65,12 @@ moveFile src dest = tryIO (renamePath src dest) >>= onrename
let (ok, e') = case r of
Left err -> (False, err)
Right _ -> (True, e)
when ok $
void $ tryIO $ removeFile src
#endif
unless ok $ do
-- delete any partial
_ <- tryIO $ removeFile tmp
void $ tryIO $ removeFile tmp
throwM e'
#ifndef mingw32_HOST_OS