diff options
-rw-r--r-- | Assistant.hs | 6 | ||||
-rw-r--r-- | Assistant/NamedThread.hs | 44 | ||||
-rw-r--r-- | Command/Unannex.hs | 22 | ||||
-rw-r--r-- | debian/changelog | 2 | ||||
-rw-r--r-- | doc/bugs/uninit_does_not_abort_when_hard_link_creation_fails.mdwn | 6 | ||||
-rw-r--r-- | doc/design/assistant/blog/day_182__it_begins.mdwn | 50 |
6 files changed, 104 insertions, 26 deletions
diff --git a/Assistant.hs b/Assistant.hs index 45c0e9f03..8a3816f4d 100644 --- a/Assistant.hs +++ b/Assistant.hs @@ -196,8 +196,10 @@ startDaemon assistant foreground startbrowser = do #ifdef WITH_WEBAPP d <- getAssistant id urlrenderer <- liftIO newUrlRenderer + mapM_ (startthread $ Just urlrenderer) +#else + mapM_ (startthread Nothing) #endif - mapM_ (startthread urlrenderer) [ watch $ commitThread #ifdef WITH_WEBAPP , assist $ webAppThread d urlrenderer False Nothing webappwaiter @@ -230,5 +232,5 @@ startDaemon assistant foreground startbrowser = do watch a = (True, a) assist a = (False, a) startthread urlrenderer (watcher, t) - | watcher || assistant = startNamedThread (Just urlrenderer) t + | watcher || assistant = startNamedThread urlrenderer t | otherwise = noop diff --git a/Assistant/NamedThread.hs b/Assistant/NamedThread.hs index fd710cf54..33af2c304 100644 --- a/Assistant/NamedThread.hs +++ b/Assistant/NamedThread.hs @@ -5,6 +5,8 @@ - Licensed under the GNU GPL version 3 or higher. -} +{-# LANGUAGE CPP #-} + module Assistant.NamedThread where import Common.Annex @@ -12,23 +14,31 @@ import Assistant.Types.NamedThread import Assistant.Types.ThreadName import Assistant.Types.DaemonStatus import Assistant.DaemonStatus -import Assistant.Alert import Assistant.Monad -import Assistant.WebApp -import Assistant.WebApp.Types import Control.Concurrent import Control.Concurrent.Async import qualified Data.Map as M -import qualified Data.Text as T import qualified Control.Exception as E +#ifdef WITH_WEBAPP +import Assistant.WebApp +import Assistant.WebApp.Types +import Assistant.Alert +import qualified Data.Text as T +#endif + {- Starts a named thread, if it's not already running. - - Named threads are run by a management thread, so if they crash - an alert is displayed, allowing the thread to be restarted. -} +#ifdef WITH_WEBAPP startNamedThread :: Maybe UrlRenderer -> NamedThread -> Assistant () startNamedThread urlrenderer namedthread@(NamedThread name a) = do +#else +startNamedThread :: Maybe Bool -> NamedThread -> Assistant () +startNamedThread urlrenderer namedthread@(NamedThread name a) = do +#endif m <- startedThreads <$> getDaemonStatus case M.lookup name m of Nothing -> start @@ -54,24 +64,26 @@ startNamedThread urlrenderer namedthread@(NamedThread name a) = do Right _ -> noop Left e -> do let msg = unwords - [ fromThreadName name + [ fromThreadName $ threadName d , "crashed:", show e ] hPutStrLn stderr msg - button <- runAssistant d mkbutton +#ifdef WITH_WEBAPP + button <- runAssistant d $ + case urlrenderer of + Nothing -> return Nothing + Just renderer -> do + close <- asIO1 removeAlert + url <- liftIO $ renderUrl renderer (RestartThreadR name) [] + return $ Just $ AlertButton + { buttonLabel = T.pack "Restart Thread" + , buttonUrl = url + , buttonAction = Just close + } runAssistant d $ void $ addAlert $ (warningAlert (fromThreadName name) msg) { alertButton = button } - mkbutton = case urlrenderer of - Nothing -> return Nothing - Just renderer -> do - close <- asIO1 removeAlert - url <- liftIO $ renderUrl renderer (RestartThreadR name) [] - return $ Just $ AlertButton - { buttonLabel = T.pack "Restart Thread" - , buttonUrl = url - , buttonAction = Just close - } +#endif namedThreadId :: NamedThread -> Assistant (Maybe ThreadId) namedThreadId (NamedThread name _) = do diff --git a/Command/Unannex.hs b/Command/Unannex.hs index c5ab028cd..0e691710a 100644 --- a/Command/Unannex.hs +++ b/Command/Unannex.hs @@ -49,14 +49,20 @@ cleanup file key = do void $ liftIO clean ifM (Annex.getState Annex.fast) - ( do - -- fast mode: hard link to content in annex - src <- inRepo $ gitAnnexLocation key - liftIO $ createLink src file - thawContent file - , do - fromAnnex key file - logStatus key InfoMissing + ( goFast + , go ) return True + where + goFast = do + -- fast mode: hard link to content in annex + src <- inRepo $ gitAnnexLocation key + -- creating a hard link could fall; fall back to non fast mode + ifM (liftIO $ catchBoolIO $ createLink src file >> return True) + ( thawContent file + , go + ) + go = do + fromAnnex key file + logStatus key InfoMissing diff --git a/debian/changelog b/debian/changelog index e67147f3d..f5ae18543 100644 --- a/debian/changelog +++ b/debian/changelog @@ -11,6 +11,8 @@ git-annex (3.20130125) UNRELEASED; urgency=low * assistant: Fix location log when adding new file in direct mode. * Deal with stale mappings for deleted file in direct mode. * pre-commit: Update direct mode mappings. + * uninit, unannex --fast: If hard link creation fails, fall back to slow + mode. -- Joey Hess <joeyh@debian.org> Sat, 26 Jan 2013 15:48:40 +1100 diff --git a/doc/bugs/uninit_does_not_abort_when_hard_link_creation_fails.mdwn b/doc/bugs/uninit_does_not_abort_when_hard_link_creation_fails.mdwn index 9488d6fba..2d98929ab 100644 --- a/doc/bugs/uninit_does_not_abort_when_hard_link_creation_fails.mdwn +++ b/doc/bugs/uninit_does_not_abort_when_hard_link_creation_fails.mdwn @@ -39,3 +39,9 @@ Issue the following commands on a file system where hard links are disabled: git-annex should probably not be used on a file system where hard links are disabled. However, if the user is not aware that he's using git-annex on such a filesystem, he will accidently delete his annexed files by issuing a `git annex uninit` command. + +> git-annex needs a POSIX filesystem, which includes the ability to create +> hard links. The `git annex add` in the example above will fail +> trying to create a hard link with current versions. +> +> I've made uninit fall back to a non-hard link mode. [[done]] --[[Joey]] diff --git a/doc/design/assistant/blog/day_182__it_begins.mdwn b/doc/design/assistant/blog/day_182__it_begins.mdwn new file mode 100644 index 000000000..48daea78f --- /dev/null +++ b/doc/design/assistant/blog/day_182__it_begins.mdwn @@ -0,0 +1,50 @@ +I need an Android development environment. I briefly looked into rooting +the Asus Transformer so I could put a Debian chroot on it and build +git-annex in there, but this quickly devolved to the typical maze of +forum posts all containing poor instructions and dead links. Not worth it. + +Instead, I'm doing builds on my Sheevaplug, and once I have a static armel +binary, will see what I need to do to get it running on Android. + +Fixed building with the webapp disabled, was broken by recent improvements. +I'll be building without the webapp on arm initially, because ghci/template +haskell on arm is still getting sorted out. (I tried ghc 7.6.2 and ghci is +available, but doesn't quite work.) + +From there, I got a binary built pretty quickly (well, it's arm, so not *too* +quickly). Then tried to make it static by appending +`-optl-static -optl-pthread` to the ghc command line. +This failed with a bunch of errors: + +<pre> +/usr/lib/gcc/arm-linux-gnueabi/4.6/../../../arm-linux-gnueabi/libxml2.a(nanohttp.o): In function `xmlNanoHTTPMethodRedir': (.text+0x2128): undefined reference to `inflateInit2_' +/usr/lib/gcc/arm-linux-gnueabi/4.6/../../../arm-linux-gnueabi/libxml2.a(xzlib.o): In function `xz_decomp': (.text+0x36c): undefined reference to `lzma_code' +... +</pre> + +Disabling DBUS and (temporarily) XMPP got around that. + +Result! + +<pre> +joey@leech:~/git-annex>ldd tmp/git-annex + not a dynamic executable +joey@leech:~/git-annex>ls -lha tmp/git-annex +-rwxr-xr-x 1 joey joey 18M Feb 6 16:23 tmp/git-annex* +</pre> + +Next: Copy binary to Android device, and watch it fail in some interesting way. +Repeat. + +--- + +Also more bug triage this morning... + +Got the pre-commit hook to update direct mode mappings. +Uses `git diff-index HEAD` to find out what's changed. The only +tricky part was detecting when `HEAD` doesn't exist yet. Git's +plumbing is deficient in this area. Anyway, the mappings get updated +much better now. + +Fixed a wacky bug where `git annex uninit` behaved badly on a filesystem +that does not support hardlinks. |