convert renameFile to moveFile to support cross-device moves

Improve handling of some .git/annex/ subdirectories being on other
filesystems, in the bittorrent special remote, and youtube-dl integration,
and git-annex addurl.

The only one of these that I've confirmed to be a problem is in the
bittorrent special remote when .git/annex/tmp and .git/annex/othertmp are
on different filesystems.

As well as auditing for renameFile, also audited for createLink, all of
those are ok as are the other remaining renameFile calls. Also audited all
code paths that use .git/annex/othertmp, and did not find any other
cross-device problems. So, removing mention of othertmp needing to be on
the same device.

Sponsored-by: Dartmouth College's Datalad project
This commit is contained in:
Joey Hess 2022-12-20 15:17:50 -04:00
parent 5cbfb74391
commit 9d60385001
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
6 changed files with 26 additions and 14 deletions

View file

@ -217,7 +217,7 @@ downloadTorrentFile u = do
ok <- Url.withUrlOptions $
Url.download nullMeterUpdate Nothing u f
when ok $
liftIO $ renameFile f (fromRawFilePath torrent)
liftIO $ moveFile (toRawFilePath f) torrent
return ok
)
@ -228,7 +228,7 @@ downloadMagnetLink u metadir dest = ifM download
<$> dirContents metadir
case ts of
(t:[]) -> do
renameFile t dest
moveFile (toRawFilePath t) (toRawFilePath dest)
return True
_ -> return False
, return False
@ -256,7 +256,7 @@ downloadTorrentContent k u dest filenum p = do
showOutput
ifM (download torrent downloaddir <&&> liftIO (doesFileExist dlf))
( do
liftIO $ renameFile dlf dest
liftIO $ moveFile (toRawFilePath dlf) (toRawFilePath dest)
-- The downloaddir is not removed here,
-- so if aria downloaded parts of other
-- files, and this is called again, it will