From 2840105ec4742bf7d2fb3ea6ee9aa80808d0d775 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 21 Sep 2012 19:43:15 -0400 Subject: default annex.delayadd to 1 on OSX --- Assistant/Threads/Watcher.hs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'Assistant') 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 -- cgit v1.2.3