add globallyAvailable to remotes

This commit is contained in:
Joey Hess 2013-03-15 19:16:13 -04:00
parent 57e5960758
commit 449520a573
12 changed files with 23 additions and 4 deletions

View file

@ -53,15 +53,18 @@ calcSyncRemotes = do
let good r = Remote.uuid r `elem` alive let good r = Remote.uuid r `elem` alive
let syncable = filter good rs let syncable = filter good rs
let nonxmpp = filter (not . isXMPPRemote) syncable let nonxmpp = filter (not . isXMPPRemote) syncable
liftIO $ print (nonxmpp, map Remote.globallyAvailable nonxmpp)
return $ \dstatus -> dstatus return $ \dstatus -> dstatus
{ syncRemotes = syncable { syncRemotes = syncable
, syncGitRemotes = , syncGitRemotes =
filter (not . Remote.specialRemote) syncable filter (not . Remote.specialRemote) syncable
, syncDataRemotes = nonxmpp , syncDataRemotes = nonxmpp
, syncingToCloudRemote = , syncingToCloudRemote = any iscloud nonxmpp
any (Git.repoIsUrl . Remote.repo) nonxmpp
} }
where
iscloud r = not (Remote.readonly r) && Remote.globallyAvailable r
{- Updates the sycRemotes list from the list of all remotes in Annex state. -} {- Updates the sycRemotes list from the list of all remotes in Annex state. -}
updateSyncRemotes :: Assistant () updateSyncRemotes :: Assistant ()
@ -69,6 +72,7 @@ updateSyncRemotes = do
modifyDaemonStatus_ =<< liftAnnex calcSyncRemotes modifyDaemonStatus_ =<< liftAnnex calcSyncRemotes
status <- getDaemonStatus status <- getDaemonStatus
liftIO $ sendNotification $ syncRemotesNotifier status liftIO $ sendNotification $ syncRemotesNotifier status
when (syncingToCloudRemote status) $ when (syncingToCloudRemote status) $
updateAlertMap $ updateAlertMap $
M.filter $ \alert -> M.filter $ \alert ->

View file

@ -293,7 +293,10 @@ checkCloudRepos :: UrlRenderer -> Remote -> Assistant ()
-- TODO only display if needed -- TODO only display if needed
checkCloudRepos urlrenderer r = checkCloudRepos urlrenderer r =
#ifdef WITH_WEBAPP #ifdef WITH_WEBAPP
cloudRepoNeeded urlrenderer (Remote.uuid r) unlessM (syncingToCloudRemote <$> getDaemonStatus) $
cloudRepoNeeded urlrenderer (Remote.uuid r)
#else
noop
#endif #endif
writeChunk :: Handle -> B.ByteString -> IO () writeChunk :: Handle -> B.ByteString -> IO ()

View file

@ -67,6 +67,7 @@ gen r u c gc = do
then Just buprepo then Just buprepo
else Nothing else Nothing
, remotetype = remote , remotetype = remote
, globallyAvailable = not $ bupLocal buprepo
, readonly = False , readonly = False
} }
return $ encryptableRemote c return $ encryptableRemote c

View file

@ -57,6 +57,7 @@ gen r u c gc = do
gitconfig = gc, gitconfig = gc,
localpath = Just dir, localpath = Just dir,
readonly = False, readonly = False,
globallyAvailable = False,
remotetype = remote remotetype = remote
} }
where where

View file

@ -111,6 +111,7 @@ gen r u _ gc = go <$> remoteCost gc defcst
, repo = r , repo = r
, gitconfig = gc , gitconfig = gc
, readonly = Git.repoIsHttp r , readonly = Git.repoIsHttp r
, globallyAvailable = not $ Git.repoIsLocal r || Git.repoIsLocalUnknown r
, remotetype = remote , remotetype = remote
} }

View file

@ -63,6 +63,7 @@ gen r u c gc = new <$> remoteCost gc veryExpensiveRemoteCost
gitconfig = gc, gitconfig = gc,
localpath = Nothing, localpath = Nothing,
readonly = False, readonly = False,
globallyAvailable = True,
remotetype = remote remotetype = remote
} }

View file

@ -52,6 +52,7 @@ gen r u c gc = do
repo = r, repo = r,
gitconfig = gc, gitconfig = gc,
readonly = False, readonly = False,
globallyAvailable = False,
remotetype = remote remotetype = remote
} }
where where

View file

@ -60,14 +60,16 @@ gen r u c gc = do
, config = M.empty , config = M.empty
, repo = r , repo = r
, gitconfig = gc , gitconfig = gc
, localpath = if rsyncUrlIsPath $ rsyncUrl o , localpath = if islocal
then Just $ rsyncUrl o then Just $ rsyncUrl o
else Nothing else Nothing
, readonly = False , readonly = False
, globallyAvailable = not $ islocal
, remotetype = remote , remotetype = remote
} }
where where
o = RsyncOpts url opts escape o = RsyncOpts url opts escape
islocal = rsyncUrlIsPath $ rsyncUrl o
url = fromMaybe (error "missing rsyncurl") $ remoteAnnexRsyncUrl gc url = fromMaybe (error "missing rsyncurl") $ remoteAnnexRsyncUrl gc
opts = map Param $ filter safe $ remoteAnnexRsyncOptions gc opts = map Param $ filter safe $ remoteAnnexRsyncOptions gc
escape = M.lookup "shellescape" c /= Just "no" escape = M.lookup "shellescape" c /= Just "no"

View file

@ -62,6 +62,7 @@ gen r u c gc = new <$> remoteCost gc expensiveRemoteCost
gitconfig = gc, gitconfig = gc,
localpath = Nothing, localpath = Nothing,
readonly = False, readonly = False,
globallyAvailable = True,
remotetype = remote remotetype = remote
} }

View file

@ -54,6 +54,7 @@ gen r _ _ gc =
localpath = Nothing, localpath = Nothing,
repo = r, repo = r,
readonly = True, readonly = True,
globallyAvailable = True,
remotetype = remote remotetype = remote
} }

View file

@ -69,6 +69,7 @@ gen r u c gc = new <$> remoteCost gc expensiveRemoteCost
gitconfig = gc, gitconfig = gc,
localpath = Nothing, localpath = Nothing,
readonly = False, readonly = False,
globallyAvailable = True,
remotetype = remote remotetype = remote
} }

View file

@ -74,6 +74,8 @@ data RemoteA a = Remote {
localpath :: Maybe FilePath, localpath :: Maybe FilePath,
-- a Remote can be known to be readonly -- a Remote can be known to be readonly
readonly :: Bool, readonly :: Bool,
-- a Remote can be globally available. (Ie, "in the cloud".)
globallyAvailable :: Bool,
-- the type of the remote -- the type of the remote
remotetype :: RemoteTypeA a remotetype :: RemoteTypeA a
} }