From 449520a57337ef24d1e3195956710226dd2b7f4d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 15 Mar 2013 19:16:13 -0400 Subject: [PATCH] add globallyAvailable to remotes --- Assistant/DaemonStatus.hs | 8 ++++++-- Assistant/XMPP/Git.hs | 5 ++++- Remote/Bup.hs | 1 + Remote/Directory.hs | 1 + Remote/Git.hs | 1 + Remote/Glacier.hs | 1 + Remote/Hook.hs | 1 + Remote/Rsync.hs | 4 +++- Remote/S3.hs | 1 + Remote/Web.hs | 1 + Remote/WebDAV.hs | 1 + Types/Remote.hs | 2 ++ 12 files changed, 23 insertions(+), 4 deletions(-) diff --git a/Assistant/DaemonStatus.hs b/Assistant/DaemonStatus.hs index 5df2267f70..6c71c60eb8 100644 --- a/Assistant/DaemonStatus.hs +++ b/Assistant/DaemonStatus.hs @@ -53,15 +53,18 @@ calcSyncRemotes = do let good r = Remote.uuid r `elem` alive let syncable = filter good rs let nonxmpp = filter (not . isXMPPRemote) syncable + + liftIO $ print (nonxmpp, map Remote.globallyAvailable nonxmpp) return $ \dstatus -> dstatus { syncRemotes = syncable , syncGitRemotes = filter (not . Remote.specialRemote) syncable , syncDataRemotes = nonxmpp - , syncingToCloudRemote = - any (Git.repoIsUrl . Remote.repo) nonxmpp + , syncingToCloudRemote = any iscloud nonxmpp } + where + iscloud r = not (Remote.readonly r) && Remote.globallyAvailable r {- Updates the sycRemotes list from the list of all remotes in Annex state. -} updateSyncRemotes :: Assistant () @@ -69,6 +72,7 @@ updateSyncRemotes = do modifyDaemonStatus_ =<< liftAnnex calcSyncRemotes status <- getDaemonStatus liftIO $ sendNotification $ syncRemotesNotifier status + when (syncingToCloudRemote status) $ updateAlertMap $ M.filter $ \alert -> diff --git a/Assistant/XMPP/Git.hs b/Assistant/XMPP/Git.hs index 74ce4b7259..135c68fbcf 100644 --- a/Assistant/XMPP/Git.hs +++ b/Assistant/XMPP/Git.hs @@ -293,7 +293,10 @@ checkCloudRepos :: UrlRenderer -> Remote -> Assistant () -- TODO only display if needed checkCloudRepos urlrenderer r = #ifdef WITH_WEBAPP - cloudRepoNeeded urlrenderer (Remote.uuid r) + unlessM (syncingToCloudRemote <$> getDaemonStatus) $ + cloudRepoNeeded urlrenderer (Remote.uuid r) +#else + noop #endif writeChunk :: Handle -> B.ByteString -> IO () diff --git a/Remote/Bup.hs b/Remote/Bup.hs index 43d28a40f2..d168f07156 100644 --- a/Remote/Bup.hs +++ b/Remote/Bup.hs @@ -67,6 +67,7 @@ gen r u c gc = do then Just buprepo else Nothing , remotetype = remote + , globallyAvailable = not $ bupLocal buprepo , readonly = False } return $ encryptableRemote c diff --git a/Remote/Directory.hs b/Remote/Directory.hs index da75fb794b..be533d038f 100644 --- a/Remote/Directory.hs +++ b/Remote/Directory.hs @@ -57,6 +57,7 @@ gen r u c gc = do gitconfig = gc, localpath = Just dir, readonly = False, + globallyAvailable = False, remotetype = remote } where diff --git a/Remote/Git.hs b/Remote/Git.hs index b08166bfaa..207655b4e9 100644 --- a/Remote/Git.hs +++ b/Remote/Git.hs @@ -111,6 +111,7 @@ gen r u _ gc = go <$> remoteCost gc defcst , repo = r , gitconfig = gc , readonly = Git.repoIsHttp r + , globallyAvailable = not $ Git.repoIsLocal r || Git.repoIsLocalUnknown r , remotetype = remote } diff --git a/Remote/Glacier.hs b/Remote/Glacier.hs index b7e002b3d0..ea5df31e58 100644 --- a/Remote/Glacier.hs +++ b/Remote/Glacier.hs @@ -63,6 +63,7 @@ gen r u c gc = new <$> remoteCost gc veryExpensiveRemoteCost gitconfig = gc, localpath = Nothing, readonly = False, + globallyAvailable = True, remotetype = remote } diff --git a/Remote/Hook.hs b/Remote/Hook.hs index b6b4d87882..97691d075c 100644 --- a/Remote/Hook.hs +++ b/Remote/Hook.hs @@ -52,6 +52,7 @@ gen r u c gc = do repo = r, gitconfig = gc, readonly = False, + globallyAvailable = False, remotetype = remote } where diff --git a/Remote/Rsync.hs b/Remote/Rsync.hs index c303316ab1..1425601ad3 100644 --- a/Remote/Rsync.hs +++ b/Remote/Rsync.hs @@ -60,14 +60,16 @@ gen r u c gc = do , config = M.empty , repo = r , gitconfig = gc - , localpath = if rsyncUrlIsPath $ rsyncUrl o + , localpath = if islocal then Just $ rsyncUrl o else Nothing , readonly = False + , globallyAvailable = not $ islocal , remotetype = remote } where o = RsyncOpts url opts escape + islocal = rsyncUrlIsPath $ rsyncUrl o url = fromMaybe (error "missing rsyncurl") $ remoteAnnexRsyncUrl gc opts = map Param $ filter safe $ remoteAnnexRsyncOptions gc escape = M.lookup "shellescape" c /= Just "no" diff --git a/Remote/S3.hs b/Remote/S3.hs index 8d487de22b..0ca86f1ff5 100644 --- a/Remote/S3.hs +++ b/Remote/S3.hs @@ -62,6 +62,7 @@ gen r u c gc = new <$> remoteCost gc expensiveRemoteCost gitconfig = gc, localpath = Nothing, readonly = False, + globallyAvailable = True, remotetype = remote } diff --git a/Remote/Web.hs b/Remote/Web.hs index 38546c7174..b0d12002c6 100644 --- a/Remote/Web.hs +++ b/Remote/Web.hs @@ -54,6 +54,7 @@ gen r _ _ gc = localpath = Nothing, repo = r, readonly = True, + globallyAvailable = True, remotetype = remote } diff --git a/Remote/WebDAV.hs b/Remote/WebDAV.hs index a06a4eb111..3b729fe832 100644 --- a/Remote/WebDAV.hs +++ b/Remote/WebDAV.hs @@ -69,6 +69,7 @@ gen r u c gc = new <$> remoteCost gc expensiveRemoteCost gitconfig = gc, localpath = Nothing, readonly = False, + globallyAvailable = True, remotetype = remote } diff --git a/Types/Remote.hs b/Types/Remote.hs index b8c603c655..fe22604474 100644 --- a/Types/Remote.hs +++ b/Types/Remote.hs @@ -74,6 +74,8 @@ data RemoteA a = Remote { localpath :: Maybe FilePath, -- a Remote can be known to be readonly readonly :: Bool, + -- a Remote can be globally available. (Ie, "in the cloud".) + globallyAvailable :: Bool, -- the type of the remote remotetype :: RemoteTypeA a }