summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-11-17 14:58:35 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-11-17 14:58:35 -0400
commitfd17f8e97390ffa72e90a4532c10f2848764c580 (patch)
tree3ff329e640a11b6c3ef62859896e7390dd23b1f7
parent9ed7e9be8f32b3795c5252641a11f3500a6dea28 (diff)
webapp: Check annex.version.
-rw-r--r--Assistant.hs69
-rw-r--r--Assistant/Threads/WebApp.hs4
-rw-r--r--Command/Watch.hs2
-rw-r--r--Command/WebApp.hs14
-rw-r--r--Upgrade.hs16
-rw-r--r--debian/changelog1
-rw-r--r--doc/bugs/webapp_usability:_fails_mysteriously_on_newer_repo_layouts.mdwn2
7 files changed, 66 insertions, 42 deletions
diff --git a/Assistant.hs b/Assistant.hs
index 3f4c4fabd..00746b785 100644
--- a/Assistant.hs
+++ b/Assistant.hs
@@ -64,8 +64,8 @@ stopDaemon = liftIO . Utility.Daemon.stopDaemon =<< fromRepo gitAnnexPidFile
-
- startbrowser is passed the url and html shim file, as well as the original
- stdout and stderr descriptors. -}
-startDaemon :: Bool -> Bool -> Maybe Duration -> Maybe HostName -> Maybe (Maybe Handle -> Maybe Handle -> String -> FilePath -> IO ()) -> Annex ()
-startDaemon assistant foreground startdelay listenhost startbrowser = do
+startDaemon :: Bool -> Bool -> Maybe Duration -> Maybe String -> Maybe HostName -> Maybe (Maybe Handle -> Maybe Handle -> String -> FilePath -> IO ()) -> Annex ()
+startDaemon assistant foreground startdelay cannotrun listenhost startbrowser = do
Annex.changeState $ \s -> s { Annex.daemon = True }
pidfile <- fromRepo gitAnnexPidFile
logfile <- fromRepo gitAnnexLogFile
@@ -117,44 +117,51 @@ startDaemon assistant foreground startdelay listenhost startbrowser = do
#endif
notice ["starting", desc, "version", SysConfig.packageversion]
urlrenderer <- liftIO newUrlRenderer
- mapM_ (startthread urlrenderer)
- [ watch $ commitThread
#ifdef WITH_WEBAPP
- , assist $ webAppThread d urlrenderer False listenhost Nothing webappwaiter
+ let webappthread = [ assist $ webAppThread d urlrenderer False cannotrun listenhost Nothing webappwaiter ]
+#else
+ let webappthread = []
+#endif
+ let threads = if isJust cannotrun
+ then webappthread
+ else webappthread ++
+ [ watch $ commitThread
+#ifdef WITH_WEBAPP
#ifdef WITH_PAIRING
- , assist $ pairListenerThread urlrenderer
+ , assist $ pairListenerThread urlrenderer
#endif
#ifdef WITH_XMPP
- , assist $ xmppClientThread urlrenderer
- , assist $ xmppSendPackThread urlrenderer
- , assist $ xmppReceivePackThread urlrenderer
+ , assist $ xmppClientThread urlrenderer
+ , assist $ xmppSendPackThread urlrenderer
+ , assist $ xmppReceivePackThread urlrenderer
#endif
#endif
- , assist $ pushThread
- , assist $ pushRetryThread
- , assist $ mergeThread
- , assist $ transferWatcherThread
- , assist $ transferPollerThread
- , assist $ transfererThread
- , assist $ daemonStatusThread
- , assist $ sanityCheckerDailyThread
- , assist $ sanityCheckerHourlyThread
- , assist $ problemFixerThread urlrenderer
+ , assist $ pushThread
+ , assist $ pushRetryThread
+ , assist $ mergeThread
+ , assist $ transferWatcherThread
+ , assist $ transferPollerThread
+ , assist $ transfererThread
+ , assist $ daemonStatusThread
+ , assist $ sanityCheckerDailyThread
+ , assist $ sanityCheckerHourlyThread
+ , assist $ problemFixerThread urlrenderer
#ifdef WITH_CLIBS
- , assist $ mountWatcherThread urlrenderer
+ , assist $ mountWatcherThread urlrenderer
#endif
- , assist $ netWatcherThread
- , assist $ netWatcherFallbackThread
- , assist $ transferScannerThread urlrenderer
- , assist $ cronnerThread urlrenderer
- , assist $ configMonitorThread
- , assist $ glacierThread
- , watch $ watchThread
- -- must come last so that all threads that wait
- -- on it have already started waiting
- , watch $ sanityCheckerStartupThread startdelay
- ]
+ , assist $ netWatcherThread
+ , assist $ netWatcherFallbackThread
+ , assist $ transferScannerThread urlrenderer
+ , assist $ cronnerThread urlrenderer
+ , assist $ configMonitorThread
+ , assist $ glacierThread
+ , watch $ watchThread
+ -- must come last so that all threads that wait
+ -- on it have already started waiting
+ , watch $ sanityCheckerStartupThread startdelay
+ ]
+ mapM_ (startthread urlrenderer) threads
liftIO waitForTermination
watch a = (True, a)
diff --git a/Assistant/Threads/WebApp.hs b/Assistant/Threads/WebApp.hs
index a5f4f4201..b380094d6 100644
--- a/Assistant/Threads/WebApp.hs
+++ b/Assistant/Threads/WebApp.hs
@@ -52,11 +52,12 @@ webAppThread
:: AssistantData
-> UrlRenderer
-> Bool
+ -> Maybe String
-> Maybe HostName
-> Maybe (IO Url)
-> Maybe (Url -> FilePath -> IO ())
-> NamedThread
-webAppThread assistantdata urlrenderer noannex listenhost postfirstrun onstartup = thread $ liftIO $ do
+webAppThread assistantdata urlrenderer noannex cannotrun listenhost postfirstrun onstartup = thread $ liftIO $ do
#ifdef __ANDROID__
when (isJust listenhost) $
-- See Utility.WebApp
@@ -68,6 +69,7 @@ webAppThread assistantdata urlrenderer noannex listenhost postfirstrun onstartup
<*> getreldir
<*> pure staticRoutes
<*> pure postfirstrun
+ <*> pure cannotrun
<*> pure noannex
<*> pure listenhost
setUrlRenderer urlrenderer $ yesodRender webapp (pack "")
diff --git a/Command/Watch.hs b/Command/Watch.hs
index 0b34b0f84..a33fc633c 100644
--- a/Command/Watch.hs
+++ b/Command/Watch.hs
@@ -32,5 +32,5 @@ start :: Bool -> Bool -> Bool -> Maybe Duration -> CommandStart
start assistant foreground stopdaemon startdelay = do
if stopdaemon
then stopDaemon
- else startDaemon assistant foreground startdelay Nothing Nothing -- does not return
+ else startDaemon assistant foreground startdelay Nothing Nothing Nothing -- does not return
stop
diff --git a/Command/WebApp.hs b/Command/WebApp.hs
index 88c1537d0..70f28a113 100644
--- a/Command/WebApp.hs
+++ b/Command/WebApp.hs
@@ -30,6 +30,8 @@ import qualified Git.CurrentRepo
import qualified Annex
import Config.Files
import qualified Option
+import Upgrade
+import Annex.Version
import Control.Concurrent
import Control.Concurrent.STM
@@ -56,10 +58,14 @@ start = start' True
start' :: Bool -> Maybe HostName -> CommandStart
start' allowauto listenhost = do
liftIO ensureInstalled
- ifM isInitialized ( go , auto )
+ ifM isInitialized
+ ( go
+ , auto
+ )
stop
where
go = do
+ cannotrun <- needsUpgrade . fromMaybe (error "no version") =<< getVersion
browser <- fromRepo webBrowser
f <- liftIO . absPath =<< fromRepo gitAnnexHtmlShim
ifM (checkpid <&&> checkshim f)
@@ -69,7 +75,7 @@ start' allowauto listenhost = do
url <- liftIO . readFile
=<< fromRepo gitAnnexUrlFile
liftIO $ openBrowser browser f url Nothing Nothing
- , startDaemon True True Nothing listenhost $ Just $
+ , startDaemon True True Nothing cannotrun listenhost $ Just $
\origout origerr url htmlshim ->
if isJust listenhost
then maybe noop (`hPutStrLn` url) origout
@@ -133,7 +139,7 @@ firstRun listenhost = do
let callback a = Just $ a v
runAssistant d $ do
startNamedThread urlrenderer $
- webAppThread d urlrenderer True listenhost
+ webAppThread d urlrenderer True Nothing listenhost
(callback signaler)
(callback mainthread)
waitNamedThreads
@@ -155,7 +161,7 @@ firstRun listenhost = do
_wait <- takeMVar v
state <- Annex.new =<< Git.CurrentRepo.get
Annex.eval state $
- startDaemon True True Nothing listenhost $ Just $
+ startDaemon True True Nothing Nothing listenhost $ Just $
sendurlback v
sendurlback v _origout _origerr url _htmlshim = do
recordUrl url
diff --git a/Upgrade.hs b/Upgrade.hs
index 59cca3fe4..fe5dd887d 100644
--- a/Upgrade.hs
+++ b/Upgrade.hs
@@ -19,15 +19,21 @@ import qualified Upgrade.V2
import qualified Upgrade.V4
checkUpgrade :: Version -> Annex ()
-checkUpgrade v
- | v `elem` supportedVersions = noop
- | v `elem` autoUpgradeableVersions = unlessM (upgrade True) $
- err "Automatic upgrade failed!"
+checkUpgrade = maybe noop error <=< needsUpgrade
+
+needsUpgrade :: Version -> Annex (Maybe String)
+needsUpgrade v
+ | v `elem` supportedVersions = ok
+ | v `elem` autoUpgradeableVersions = ifM (upgrade True)
+ ( ok
+ , err "Automatic upgrade failed!"
+ )
| v `elem` upgradableVersions = err "Upgrade this repository: git-annex upgrade"
| otherwise = err "Upgrade git-annex."
where
- err msg = error $ "Repository version " ++ v ++
+ err msg = return $ Just $ "Repository version " ++ v ++
" is not supported. " ++ msg
+ ok = return Nothing
upgrade :: Bool -> Annex Bool
upgrade automatic = go =<< getVersion
diff --git a/debian/changelog b/debian/changelog
index 9e8886614..99269e48a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -39,6 +39,7 @@ git-annex (5.20131102) UNRELEASED; urgency=low
* Switched to the tasty test framework.
* Android: Adjust default .gitignore to ignore .thumbnails at any location
in the tree, not just at its top.
+ * webapp: Check annex.version.
-- Joey Hess <joeyh@debian.org> Wed, 06 Nov 2013 16:14:14 -0400
diff --git a/doc/bugs/webapp_usability:_fails_mysteriously_on_newer_repo_layouts.mdwn b/doc/bugs/webapp_usability:_fails_mysteriously_on_newer_repo_layouts.mdwn
index 78a0847b6..73908f40b 100644
--- a/doc/bugs/webapp_usability:_fails_mysteriously_on_newer_repo_layouts.mdwn
+++ b/doc/bugs/webapp_usability:_fails_mysteriously_on_newer_repo_layouts.mdwn
@@ -30,3 +30,5 @@ the failing version is running the one from wheezy backports.
### Please provide any additional information below.
screenshot coming up.
+
+> [[fixed|done]] --[[Joey]]