summaryrefslogtreecommitdiff
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
parent0b2b67e809b1ff7b6f623db73600717580080733 (diff)
default annex.delayadd to 1 on OSX
-rw-r--r--Assistant/Threads/Watcher.hs17
-rw-r--r--doc/bugs/pasting_into_annex_on_OSX.mdwn2
-rw-r--r--doc/design/assistant/OSX.mdwn7
-rw-r--r--doc/git-annex.mdwn3
4 files changed, 26 insertions, 3 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
diff --git a/doc/bugs/pasting_into_annex_on_OSX.mdwn b/doc/bugs/pasting_into_annex_on_OSX.mdwn
index 9683cd15d..0c266ae6b 100644
--- a/doc/bugs/pasting_into_annex_on_OSX.mdwn
+++ b/doc/bugs/pasting_into_annex_on_OSX.mdwn
@@ -14,3 +14,5 @@ OSX - 10.6. zsh. git-annex version: 3.20120826
Please provide any additional information below.
+> Ok, I've put in the one second delay to adding by default on OSX.
+> I consider this bug [[done]], at least for now..
diff --git a/doc/design/assistant/OSX.mdwn b/doc/design/assistant/OSX.mdwn
index 37fb978e4..e34e88421 100644
--- a/doc/design/assistant/OSX.mdwn
+++ b/doc/design/assistant/OSX.mdwn
@@ -4,3 +4,10 @@ Misc OSX porting things:
* add webapp to OSX menu somehow
* Use OSX's "network reachability functionality" to detect when on a network
<http://developer.apple.com/library/mac/#documentation/Networking/Conceptual/SystemConfigFrameworks/SC_Intro/SC_Intro.html#//apple_ref/doc/uid/TP40001065>
+
+Gripes:
+
+* The assistant has to wait a second when a new file is created,
+ to work around some bad behavior when pasting a file into the annex.
+ [[details|bugs/pasting_into_annex_on_OSX]]. That's one more second
+ before the file is synced out.
diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn
index 6cc1fb39d..ce7c0be3c 100644
--- a/doc/git-annex.mdwn
+++ b/doc/git-annex.mdwn
@@ -684,7 +684,8 @@ Here are all the supported configuration settings.
Makes the watch and assistant commands delay for the specified number of
seconds before adding a newly created file to the annex. Normally this
is not needed, because they already wait for all writers of the file
- to close it.
+ to close it. On Mac OSX, this defaults to 1 second, to work around
+ a bad interaction with software there.
* `remote.<name>.annex-cost`