catch chdir exception in --autostop
authorJoey Hess <joeyh@joeyh.name>
Wed, 19 Apr 2023 16:42:02 +0000 (12:42 -0400)
committerJoey Hess <joeyh@joeyh.name>
Wed, 19 Apr 2023 16:42:02 +0000 (12:42 -0400)
assistant --autostop: Avoid crashing when ~/.config/git-annex/autostart
lists a directory that it cannot chdir to.

Sponsored-by: k0ld on Patreon
CHANGELOG
Command/Assistant.hs
doc/bugs/assistant_--autostop_stops_after_nonexistant_repo.mdwn

index a01981d495fc31eb8f2f3847a9062d8e88df813d..4efdca332f7db02c21903337044202f328ac1967 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -22,6 +22,8 @@ git-annex (10.20230408) UNRELEASED; urgency=medium
     are passed.
   * configremote: New command, currently limited to changing autoenable=
     setting of a special remote.
+  * assistant --autostop: Avoid crashing when ~/.config/git-annex/autostart
+    lists a directory that it cannot chdir to.
 
  -- Joey Hess <id@joeyh.name>  Sat, 08 Apr 2023 13:57:18 -0400
 
index b999e5b2719a2ef1462b1e1a0674f523bb8bd321..66758f1941e860bca1c9ffd581975b7f4b7a713e 100644 (file)
@@ -130,8 +130,11 @@ autoStop = do
        program <- programPath
        forM_ dirs $ \d -> do
                putStrLn $ "git-annex autostop in " ++ d
-               setCurrentDirectory d
-               ifM (boolSystem program [Param "assistant", Param "--stop"])
-                       ( putStrLn "ok"
-                       , putStrLn "failed"
-                       )
+               tryIO (setCurrentDirectory d) >>= \case
+                       Right () -> ifM (boolSystem program [Param "assistant", Param "--stop"])
+                               ( putStrLn "ok"
+                               , putStrLn "failed"
+                               )
+                       Left e -> do
+                               putStrLn (show e)
+                               putStrLn "failed"
index 0ed278edd9a12968940b70f138248f109b89a1e3..712a8057cfa9d804755209f0e0304bb44b78693a 100644 (file)
@@ -21,3 +21,5 @@ git-annex version: 10.20230329-ge6a337e8e
 ### Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders)
 
 I love it! ðŸ¤©
+
+> [[fixed|done]] --[[Joey]]