more RawFilePath

Remove dup definitions and just use the RawFilePath one. </> etc are
enough faster that it's probably faster than building a String directly,
although I have not benchmarked.
This commit is contained in:
Joey Hess 2019-12-18 16:45:03 -04:00
parent 9e9def2dc0
commit 686791c4ed
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
26 changed files with 140 additions and 120 deletions

View file

@ -195,7 +195,7 @@ downloadTorrentFile u = do
createAnnexDirectory (parentDir torrent)
if isTorrentMagnetUrl u
then withOtherTmp $ \othertmp -> do
kf <- keyFile <$> torrentUrlKey u
kf <- fromRawFilePath . keyFile <$> torrentUrlKey u
let metadir = othertmp </> "torrentmeta" </> kf
createAnnexDirectory metadir
showOutput
@ -239,7 +239,7 @@ downloadTorrentContent :: Key -> URLString -> FilePath -> Int -> MeterUpdate ->
downloadTorrentContent k u dest filenum p = do
torrent <- tmpTorrentFile u
withOtherTmp $ \othertmp -> do
kf <- keyFile <$> torrentUrlKey u
kf <- fromRawFilePath . keyFile <$> torrentUrlKey u
let downloaddir = othertmp </> "torrent" </> kf
createAnnexDirectory downloaddir
f <- wantedfile torrent

View file

@ -140,7 +140,7 @@ getLocation d k = do
{- Directory where the file(s) for a key are stored. -}
storeDir :: FilePath -> Key -> FilePath
storeDir d k = addTrailingPathSeparator $
d </> fromRawFilePath (hashDirLower def k) </> keyFile k
d </> fromRawFilePath (hashDirLower def k) </> fromRawFilePath (keyFile k)
{- Check if there is enough free disk space in the remote's directory to
- store the key. Note that the unencrypted key size is checked. -}
@ -164,12 +164,13 @@ store d chunkconfig k b p = liftIO $ do
case chunkconfig of
LegacyChunks chunksize -> Legacy.store chunksize finalizeStoreGeneric k b p tmpdir destdir
_ -> do
let tmpf = tmpdir </> keyFile k
let tmpf = tmpdir </> kf
meteredWriteFile p tmpf b
finalizeStoreGeneric tmpdir destdir
return True
where
tmpdir = addTrailingPathSeparator $ d </> "tmp" </> keyFile k
tmpdir = addTrailingPathSeparator $ d </> "tmp" </> kf
kf = fromRawFilePath (keyFile k)
destdir = storeDir d k
{- Passed a temp directory that contains the files that should be placed

View file

@ -91,7 +91,7 @@ store chunksize finalizer k b p = storeHelper finalizer k $ \dests ->
retrieve :: (FilePath -> Key -> [FilePath]) -> FilePath -> Preparer Retriever
retrieve locations d basek a = withOtherTmp $ \tmpdir -> do
showLongNote "This remote uses the deprecated chunksize setting. So this will be quite slow."
let tmp = tmpdir </> keyFile basek ++ ".directorylegacy.tmp"
let tmp = tmpdir </> fromRawFilePath (keyFile basek) ++ ".directorylegacy.tmp"
a $ Just $ byteRetriever $ \k sink -> do
liftIO $ void $ withStoredFiles d locations k $ \fs -> do
forM_ fs $

View file

@ -351,9 +351,9 @@ store' :: Git.Repo -> Remote -> Remote.Rsync.RsyncOpts -> Storer
store' repo r rsyncopts
| not $ Git.repoIsUrl repo =
byteStorer $ \k b p -> guardUsable repo (return False) $ liftIO $ do
let tmpdir = Git.repoLocation repo </> "tmp" </> keyFile k
let tmpdir = Git.repoLocation repo </> "tmp" </> fromRawFilePath (keyFile k)
void $ tryIO $ createDirectoryIfMissing True tmpdir
let tmpf = tmpdir </> keyFile k
let tmpf = tmpdir </> fromRawFilePath (keyFile k)
meteredWriteFile p tmpf b
let destdir = parentDir $ gCryptLocation repo k
Remote.Directory.finalizeStoreGeneric tmpdir destdir

View file

@ -77,7 +77,7 @@ storeChunks key tmp dest storer recorder finalizer = either onerr return
warningIO (show e)
return False
basef = tmp ++ keyFile key
basef = tmp ++ fromRawFilePath (keyFile key)
tmpdests = map (basef ++ ) chunkStream
{- Given a list of destinations to use, chunks the data according to the

View file

@ -226,7 +226,7 @@ remove o k = removeGeneric o includes
[ parentDir dir
, dir
-- match content directory and anything in it
, dir </> keyFile k </> "***"
, dir </> fromRawFilePath (keyFile k) </> "***"
]
{- An empty directory is rsynced to make it delete. Everything is excluded,

View file

@ -44,7 +44,7 @@ rsyncUrls :: RsyncOpts -> Key -> [RsyncUrl]
rsyncUrls o k = map use dirHashes
where
use h = rsyncUrl o </> fromRawFilePath (hash h) </> rsyncEscape o (f </> f)
f = keyFile k
f = fromRawFilePath (keyFile k)
#ifndef mingw32_HOST_OS
hash h = h def k
#else

View file

@ -36,7 +36,7 @@ inLocation d = inDAVLocation (</> d')
{- The directory where files(s) for a key are stored. -}
keyDir :: Key -> DavLocation
keyDir k = addTrailingPathSeparator $ hashdir </> keyFile k
keyDir k = addTrailingPathSeparator $ hashdir </> fromRawFilePath (keyFile k)
where
#ifndef mingw32_HOST_OS
hashdir = fromRawFilePath $ hashDirLower def k
@ -45,7 +45,7 @@ keyDir k = addTrailingPathSeparator $ hashdir </> keyFile k
#endif
keyLocation :: Key -> DavLocation
keyLocation k = keyDir k ++ keyFile k
keyLocation k = keyDir k ++ fromRawFilePath (keyFile k)
{- Paths containing # or ? cannot be represented in an url, so fails on
- those. -}
@ -60,7 +60,7 @@ exportLocation l =
{- Where we store temporary data for a key as it's being uploaded. -}
keyTmpLocation :: Key -> DavLocation
keyTmpLocation = tmpLocation . keyFile
keyTmpLocation = tmpLocation . fromRawFilePath . keyFile
tmpLocation :: FilePath -> DavLocation
tmpLocation f = "git-annex-webdav-tmp-" ++ f