diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-01-06 18:29:07 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-01-06 18:55:56 -0400 |
commit | 2bba5bc22d049272d3328bfa6c452d3e2e50e86c (patch) | |
tree | 19feab50e43dc330038224ea98b371916ca02133 /Remote | |
parent | 014e909a449d0822eff4962a504d6a524abe8fc7 (diff) |
made parentDir return a Maybe FilePath; removed most uses of it
parentDir is less safe than takeDirectory, especially when working
with relative FilePaths. It's really only useful in loops that
want to terminate at /
This commit was sponsored by Audric SCHILTKNECHT.
Diffstat (limited to 'Remote')
-rw-r--r-- | Remote/BitTorrent.hs | 2 | ||||
-rw-r--r-- | Remote/Directory.hs | 2 | ||||
-rw-r--r-- | Remote/GCrypt.hs | 4 | ||||
-rw-r--r-- | Remote/Git.hs | 2 | ||||
-rw-r--r-- | Remote/Rsync.hs | 4 | ||||
-rw-r--r-- | Remote/Tahoe.hs | 2 |
6 files changed, 8 insertions, 8 deletions
diff --git a/Remote/BitTorrent.hs b/Remote/BitTorrent.hs index d0a35fa30..b04abe56b 100644 --- a/Remote/BitTorrent.hs +++ b/Remote/BitTorrent.hs @@ -189,7 +189,7 @@ downloadTorrentFile u = do , do showAction "downloading torrent file" showOutput - createAnnexDirectory (parentDir torrent) + createAnnexDirectory (takeDirectory torrent) if isTorrentMagnetUrl u then do tmpdir <- tmpTorrentDir u diff --git a/Remote/Directory.hs b/Remote/Directory.hs index 66a3de49f..1d9a15ea5 100644 --- a/Remote/Directory.hs +++ b/Remote/Directory.hs @@ -143,7 +143,7 @@ finalizeStoreGeneric :: FilePath -> FilePath -> IO () finalizeStoreGeneric tmp dest = do void $ tryIO $ allowWrite dest -- may already exist void $ tryIO $ removeDirectoryRecursive dest -- or not exist - createDirectoryIfMissing True (parentDir dest) + createDirectoryIfMissing True (takeDirectory dest) renameDirectory tmp dest -- may fail on some filesystems void $ tryIO $ do diff --git a/Remote/GCrypt.hs b/Remote/GCrypt.hs index 2f2ddc9f3..67021732f 100644 --- a/Remote/GCrypt.hs +++ b/Remote/GCrypt.hs @@ -315,7 +315,7 @@ store r rsyncopts void $ tryIO $ createDirectoryIfMissing True tmpdir let tmpf = tmpdir </> keyFile k meteredWriteFile p tmpf b - let destdir = parentDir $ gCryptLocation r k + let destdir = takeDirectory $ gCryptLocation r k Remote.Directory.finalizeStoreGeneric tmpdir destdir return True | Git.repoIsSsh (repo r) = if isShell r @@ -340,7 +340,7 @@ retrieve r rsyncopts remove :: Remote -> Remote.Rsync.RsyncOpts -> Remover remove r rsyncopts k | not $ Git.repoIsUrl (repo r) = guardUsable (repo r) (return False) $ - liftIO $ Remote.Directory.removeDirGeneric (Git.repoLocation (repo r)) (parentDir (gCryptLocation r k)) + liftIO $ Remote.Directory.removeDirGeneric (Git.repoLocation (repo r)) (takeDirectory (gCryptLocation r k)) | Git.repoIsSsh (repo r) = shellOrRsync r removeshell removersync | otherwise = unsupportedUrl where diff --git a/Remote/Git.hs b/Remote/Git.hs index 17b44fa6e..8e521cfe9 100644 --- a/Remote/Git.hs +++ b/Remote/Git.hs @@ -556,7 +556,7 @@ rsyncOrCopyFile rsyncparams src dest p = ifM (sameDeviceIds src dest) (docopy, dorsync) where sameDeviceIds a b = (==) <$> getDeviceId a <*> getDeviceId b - getDeviceId f = deviceID <$> liftIO (getFileStatus $ parentDir f) + getDeviceId f = deviceID <$> liftIO (getFileStatus $ takeDirectory f) docopy = liftIO $ bracket (forkIO $ watchfilesize zeroBytesProcessed) (void . tryIO . killThread) diff --git a/Remote/Rsync.hs b/Remote/Rsync.hs index ad5b77d38..72cabe2fd 100644 --- a/Remote/Rsync.hs +++ b/Remote/Rsync.hs @@ -161,7 +161,7 @@ rsyncSetup mu _ c = do store :: RsyncOpts -> Key -> FilePath -> MeterUpdate -> Annex Bool store o k src meterupdate = withRsyncScratchDir $ \tmp -> do let dest = tmp </> Prelude.head (keyPaths k) - liftIO $ createDirectoryIfMissing True $ parentDir dest + liftIO $ createDirectoryIfMissing True $ takeDirectory dest ok <- liftIO $ if canrename then do rename src dest @@ -214,7 +214,7 @@ remove o k = do - traverses directories. -} includes = concatMap use annexHashes use h = let dir = h k in - [ parentDir dir + [ takeDirectory dir , dir -- match content directory and anything in it , dir </> keyFile k </> "***" diff --git a/Remote/Tahoe.hs b/Remote/Tahoe.hs index 27bb12884..06c7590e7 100644 --- a/Remote/Tahoe.hs +++ b/Remote/Tahoe.hs @@ -153,7 +153,7 @@ tahoeConfigure configdir furl mscs = do createClient :: TahoeConfigDir -> IntroducerFurl -> IO Bool createClient configdir furl = do - createDirectoryIfMissing True (parentDir configdir) + createDirectoryIfMissing True (takeDirectory configdir) boolTahoe configdir "create-client" [ Param "--nickname", Param "git-annex" , Param "--introducer", Param furl |