]> dgit.raspbian.org Git - git-annex.git/commitdiff
completed the createDirectoryIfMissing conversion
authorJoey Hess <joeyh@joeyh.name>
Fri, 6 Mar 2020 16:52:20 +0000 (12:52 -0400)
committerJoey Hess <joeyh@joeyh.name>
Fri, 6 Mar 2020 16:55:03 +0000 (12:55 -0400)
Remaining calls in the assistant and Annex.Ssh have been audited and are ok.

Annex/Ssh.hs
Assistant/Threads/Merger.hs
Assistant/Threads/TransferWatcher.hs
Assistant/WebApp/Configurators/Edit.hs
CHANGELOG
doc/todo/stop_using_createDirectoryIfMissing_True.mdwn

index 8304e04c1aa629ec7034dfc9c998f83174239b03..e7c2114b6f8028d8950346e04cb83c82789d1875 100644 (file)
@@ -154,8 +154,11 @@ sshConnectionCachingParams socketfile =
 sshSocketDirEnv :: String
 sshSocketDirEnv = "GIT_ANNEX_SSH_SOCKET_DIR"
 
-{- ssh connection caching creates sockets, so will not work on a
- - crippled filesystem. -}
+{- Returns the directory where ssh connection caching sockets can be
+ - stored.
+ - 
+ - The directory will be created if it does not exist.
+ -}
 sshCacheDir :: Annex (Maybe FilePath)
 sshCacheDir = eitherToMaybe <$> sshCacheDir'
 
@@ -169,7 +172,10 @@ sshCacheDir' =
                                Just tmpdir -> 
                                        liftIO $ catchMsgIO $
                                                usetmpdir tmpdir
-                       , Right <$> fromRepo gitAnnexSshDir 
+                       , do
+                               d <- fromRepo gitAnnexSshDir
+                               createAnnexDirectory d
+                               return (Right d)
                        )
                , return (Left "annex.sshcaching is not set to true")
                )
@@ -221,7 +227,6 @@ prepSocket socketfile sshhost sshparams = do
        -- Cleanup at shutdown.
        Annex.addCleanup SshCachingCleanup sshCleanup
        
-       liftIO $ createDirectoryIfMissing True $ parentDir socketfile
        let socketlock = socket2lock socketfile
 
        Annex.getState Annex.concurrency >>= \case
index 82802fbb2918e29f5c4f2c9b44099a28bf51cbc4..ac9435122a7e6c12df35e83aecbca9ca631e35d5 100644 (file)
@@ -26,8 +26,9 @@ import qualified Command.Sync
 mergeThread :: NamedThread
 mergeThread = namedThread "Merger" $ do
        g <- liftAnnex gitRepo
-       let dir = fromRawFilePath (Git.localGitDir g) </> "refs"
-       liftIO $ createDirectoryIfMissing True dir
+       let gitd = fromRawFilePath (Git.localGitDir g)
+       let dir = gitd </> "refs"
+       liftIO $ createDirectoryUnder gitd dir
        let hook a = Just <$> asIO2 (runHandler a)
        changehook <- hook onChange
        errhook <- hook onErr
index 181cb10f5530f13f233c7a051754d1315395218a..e4316ffcd2b363b87826562fc366a92a3424232c 100644 (file)
@@ -15,6 +15,7 @@ import Logs.Transfer
 import Utility.DirWatcher
 import Utility.DirWatcher.Types
 import qualified Remote
+import Annex.Perms
 
 import Control.Concurrent
 import qualified Data.Map as M
@@ -24,7 +25,7 @@ import qualified Data.Map as M
 transferWatcherThread :: NamedThread
 transferWatcherThread = namedThread "TransferWatcher" $ do
        dir <- liftAnnex $ gitAnnexTransferDir <$> gitRepo
-       liftIO $ createDirectoryIfMissing True dir
+       liftAnnex $ createAnnexDirectory dir
        let hook a = Just <$> asIO2 (runHandler a)
        addhook <- hook onAdd
        delhook <- hook onDel
index 59d8d61247a510d47a8bb452c1504c0ba3d025dd..c82fbe248f0c411446f6f660ac9bdba37886e9d7 100644 (file)
@@ -41,6 +41,7 @@ import Remote.Helper.Encryptable (extractCipher, parseEncryptionConfig)
 import Types.Crypto
 import Utility.Gpg
 import Annex.UUID
+import Annex.Perms
 import Assistant.Ssh
 import Config
 import Config.GitConfig
@@ -246,9 +247,9 @@ checkAssociatedDirectory cfg (Just r) = do
        repoconfig <- M.lookup (Remote.uuid r) <$> readRemoteLog
        case repoGroup cfg of
                RepoGroupStandard gr -> case associatedDirectory repoconfig gr of
-                       Just d -> inRepo $ \g ->
-                               createDirectoryIfMissing True $
-                                       fromRawFilePath (Git.repoPath g) </> d
+                       Just d -> do
+                               top <- fromRawFilePath <$> fromRepo Git.repoPath
+                               createWorkTreeDirectory (top </> d)
                        Nothing -> noop
                _ -> noop
 
index b7b81c227a817b8253550fa0fc9122cd82f35390..cd41f23c8fde34ea124fee8bff70086a7c24b998 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,5 +1,8 @@
 git-annex (8.20200227) UNRELEASED; urgency=medium
 
+  * Improve behavior when a directory git-annex is writing to gets
+    unmounted. Previously it could in some cases re-create the mount point
+    and directory tree, and even write object contents to the wrong disk.
   * Bugfix: Don't ignore --debug when it is followed by -c.
   * whereis: If a remote fails to report on urls where a key
     is located, display a warning, rather than giving up and not displaying
index 3faca053f3914709079cbf2b9a4a227064effa34..f82555a47dd147bcfea49f1e827654885b6b7687 100644 (file)
@@ -28,3 +28,5 @@ point, which can be either .git/annex or the top of the worktree depending
 on what's being done. --[[Joey]]
 
 [[!tag confirmed]]
+
+> [[fixed|done]], all relevant calls have been converted. --[[Joey]]