summaryrefslogtreecommitdiff
path: root/Assistant
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-09-21 19:43:15 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-09-21 19:43:15 -0400
commit2840105ec4742bf7d2fb3ea6ee9aa80808d0d775 (patch)
treece31ba6d7c48c4a9b6d51dabe9f18352d54f843c /Assistant
parent0b2b67e809b1ff7b6f623db73600717580080733 (diff)
default annex.delayadd to 1 on OSX
Diffstat (limited to 'Assistant')
-rw-r--r--Assistant/Threads/Watcher.hs17
1 files changed, 15 insertions, 2 deletions
diff --git a/Assistant/Threads/Watcher.hs b/Assistant/Threads/Watcher.hs
index 41396a23c..9c3f4a941 100644
--- a/Assistant/Threads/Watcher.hs
+++ b/Assistant/Threads/Watcher.hs
@@ -5,6 +5,8 @@
- Licensed under the GNU GPL version 3 or higher.
-}
+{-# LANGUAGE CPP #-}
+
module Assistant.Threads.Watcher (
watchThread,
checkCanWatch,
@@ -58,17 +60,28 @@ needLsof = error $ unlines
, "Be warned: This can corrupt data in the annex, and make fsck complain."
]
+{- OSX needs a short delay after a file is added before locking it down,
+ - as pasting a file seems to try to set file permissions or otherwise
+ - access the file after closing it. -}
+delayaddDefault :: Maybe Seconds
+#ifdef darwin_HOST_OS
+delayaddDefault = Just $ Seconds 1
+#else
+delayaddDefault = Nothing
+#endif
+
watchThread :: ThreadState -> DaemonStatusHandle -> TransferQueue -> ChangeChan -> NamedThread
watchThread st dstatus transferqueue changechan = NamedThread thisThread $ do
delayadd <- runThreadState st $
- readish <$> getConfig (annexConfig "delayadd") ""
+ maybe delayaddDefault (Just . Seconds) . readish
+ <$> getConfig (annexConfig "delayadd") ""
void $ watchDir "." ignored (hooks delayadd) startup
debug thisThread [ "watching", "."]
where
startup = startupScan st dstatus
hook delay a = Just $ runHandler thisThread delay st dstatus transferqueue changechan a
hooks delayadd = mkWatchHooks
- { addHook = hook (Seconds <$> delayadd) onAdd
+ { addHook = hook delayadd onAdd
, delHook = hook Nothing onDel
, addSymlinkHook = hook Nothing onAddSymlink
, delDirHook = hook Nothing onDelDir