OSX assistant: Uses direct mode by default when setting up a new local repository.

This commit is contained in:
Joey Hess 2012-12-28 16:42:11 -04:00
parent 561e317506
commit c0f9810f0b
6 changed files with 37 additions and 18 deletions

View file

@ -41,9 +41,9 @@ import Data.Either
{- This thread makes git commits at appropriate times. -} {- This thread makes git commits at appropriate times. -}
commitThread :: NamedThread commitThread :: NamedThread
commitThread = NamedThread "Committer" $ do commitThread = NamedThread "Committer" $ do
delayadd <- liftAnnex $ delayadd <- liftAnnex $ do
maybe delayaddDefault (Just . Seconds) . readish v <- readish <$> getConfig (annexConfig "delayadd") ""
<$> getConfig (annexConfig "delayadd") "" maybe delayaddDefault (return . Just . Seconds) v
runEvery (Seconds 1) <~> do runEvery (Seconds 1) <~> do
-- We already waited one second as a simple rate limiter. -- We already waited one second as a simple rate limiter.
-- Next, wait until at least one change is available for -- Next, wait until at least one change is available for
@ -115,13 +115,17 @@ shouldCommit now changes
thisSecond c = now `diffUTCTime` changeTime c <= 1 thisSecond c = now `diffUTCTime` changeTime c <= 1
{- OSX needs a short delay after a file is added before locking it down, {- 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 - when using a non-direct mode repository, as pasting a file seems to
- access the file after closing it. -} - try to set file permissions or otherwise access the file after closing
delayaddDefault :: Maybe Seconds - it. -}
delayaddDefault :: Annex (Maybe Seconds)
#ifdef darwin_HOST_OS #ifdef darwin_HOST_OS
delayaddDefault = Just $ Seconds 1 delayaddDefault = ifM isDirect
( return Nothing
, return $ Just $ Seconds 1
)
#else #else
delayaddDefault = Nothing delayaddDefault = return Nothing
#endif #endif
{- If there are PendingAddChanges, or InProcessAddChanges, the files {- If there are PendingAddChanges, or InProcessAddChanges, the files

View file

@ -29,6 +29,7 @@ import Annex.UUID
import Types.StandardGroups import Types.StandardGroups
import Logs.PreferredContent import Logs.PreferredContent
import Utility.UserInfo import Utility.UserInfo
import Config
import qualified Data.Text as T import qualified Data.Text as T
import Data.Char import Data.Char
@ -144,7 +145,7 @@ getNewRepositoryR = page "Add another repository" (Just Config) $ do
FormSuccess (RepositoryPath p) -> lift $ do FormSuccess (RepositoryPath p) -> lift $ do
let path = T.unpack p let path = T.unpack p
liftIO $ makeRepo path False liftIO $ makeRepo path False
u <- liftIO $ initRepo path Nothing u <- liftIO $ initRepo True path Nothing
runAnnex () $ setStandardGroup u ClientGroup runAnnex () $ setStandardGroup u ClientGroup
liftIO $ addAutoStart path liftIO $ addAutoStart path
redirect $ SwitchToRepositoryR path redirect $ SwitchToRepositoryR path
@ -187,7 +188,7 @@ getAddDriveR = page "Add a removable drive" (Just Config) $ do
where where
make mountpoint = do make mountpoint = do
liftIO $ makerepo dir liftIO $ makerepo dir
u <- liftIO $ initRepo dir $ Just remotename u <- liftIO $ initRepo False dir $ Just remotename
r <- addremote dir remotename r <- addremote dir remotename
runAnnex () $ setStandardGroup u TransferGroup runAnnex () $ setStandardGroup u TransferGroup
syncRemote r syncRemote r
@ -246,7 +247,7 @@ startFullAssistant path = do
webapp <- getYesod webapp <- getYesod
url <- liftIO $ do url <- liftIO $ do
makeRepo path False makeRepo path False
u <- initRepo path Nothing u <- initRepo True path Nothing
inDir path $ inDir path $
setStandardGroup u ClientGroup setStandardGroup u ClientGroup
addAutoStart path addAutoStart path
@ -271,8 +272,8 @@ inDir dir a = do
state <- Annex.new =<< Git.Config.read =<< Git.Construct.fromPath dir state <- Annex.new =<< Git.Config.read =<< Git.Construct.fromPath dir
Annex.eval state a Annex.eval state a
initRepo :: FilePath -> Maybe String -> IO UUID initRepo :: Bool -> FilePath -> Maybe String -> IO UUID
initRepo dir desc = inDir dir $ do initRepo primary_assistant_repo dir desc = inDir dir $ do
{- Initialize a git-annex repository in a directory with a description. -} {- Initialize a git-annex repository in a directory with a description. -}
unlessM isInitialized $ unlessM isInitialized $
initialize desc initialize desc
@ -285,6 +286,12 @@ initRepo dir desc = inDir dir $ do
, Param "-m" , Param "-m"
, Param "created repository" , Param "created repository"
] ]
#ifdef darwin_HOST_OS
{- Use direct mode repositories by default on OSX, because
- this avoids some problems with the Finder. -}
when primary_assistant_repo $
setDirect True
#endif
getUUID getUUID
{- Adds a directory to the autostart file. -} {- Adds a directory to the autostart file. -}

5
debian/changelog vendored
View file

@ -11,6 +11,8 @@ git-annex (3.20121212) UNRELEASED; urgency=low
as well as allowing detection of modification of files in direct mode. as well as allowing detection of modification of files in direct mode.
BSD systems still use kqueue, and cannot detect modifications of existing BSD systems still use kqueue, and cannot detect modifications of existing
files in direct mode. files in direct mode.
* OSX assistant: Uses direct mode by default when setting up a new
local repository.
* kqueue: Fix bug that made broken symlinks not be noticed. * kqueue: Fix bug that made broken symlinks not be noticed.
* vicfg: Quote filename. Closes: #696193 * vicfg: Quote filename. Closes: #696193
* Bugfix: Fixed bug parsing transfer info files, where the newline after * Bugfix: Fixed bug parsing transfer info files, where the newline after
@ -26,9 +28,6 @@ git-annex (3.20121212) UNRELEASED; urgency=low
-- Joey Hess <joeyh@debian.org> Thu, 13 Dec 2012 14:06:43 -0400 -- Joey Hess <joeyh@debian.org> Thu, 13 Dec 2012 14:06:43 -0400
-- Joey Hess <joeyh@debian.org> Thu, 13 Dec 2012 14:06:43 -0400
git-annex (3.20121211) unstable; urgency=low git-annex (3.20121211) unstable; urgency=low
* webapp: Defaults to sharing box.com account info with friends, allowing * webapp: Defaults to sharing box.com account info with friends, allowing

View file

@ -31,3 +31,7 @@ The sync should be transparent but it's not, and it's error prone. It would even
Dropbox even allows to put a symlink in the dropbox directory, and it will sync the file. Dropbox even allows to put a symlink in the dropbox directory, and it will sync the file.
[[!tag /design/assistant/OSX]] [[!tag /design/assistant/OSX]]
> Now the assistant creates new repositories using direct mode on OSX.
> In direct mode, there is no locking of files; they can be modified
> directly. [[done]] --[[Joey]]

View file

@ -20,4 +20,9 @@ Please provide any additional information below.
>> Reopening since I've heard from someone else that it can still happen. >> Reopening since I've heard from someone else that it can still happen.
>> --[[Joey]] >> --[[Joey]]
>>> Closing again, since the assistant now makes new repositories on OSX
>>> using direct mode, which should avoid this problem. NB: any existing
>>> repositories you have on OSX should be switched to use direct mode by
>>> manually running `git annex direct` in them. [[done]] --[[Joey]]
[[!tag /design/assistant/OSX]] [[!tag /design/assistant/OSX]]

View file

@ -788,8 +788,8 @@ Here are all the supported configuration settings.
Makes the watch and assistant commands delay for the specified number of Makes the watch and assistant commands delay for the specified number of
seconds before adding a newly created file to the annex. Normally this 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 is not needed, because they already wait for all writers of the file
to close it. On Mac OSX, this defaults to 1 second, to work around to close it. On Mac OSX, when not using direct mode this defaults to
a bad interaction with software there. 1 second, to work around a bad interaction with software there.
* `annex.direct` * `annex.direct`