summaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
Diffstat (limited to 'Command')
-rw-r--r--Command/Fsck.hs2
-rw-r--r--Command/Status.hs2
-rw-r--r--Command/Unused.hs14
-rw-r--r--Command/Vicfg.hs31
4 files changed, 30 insertions, 19 deletions
diff --git a/Command/Fsck.hs b/Command/Fsck.hs
index 980a1e3cf..3b89c550c 100644
--- a/Command/Fsck.hs
+++ b/Command/Fsck.hs
@@ -104,7 +104,7 @@ withIncremental = withValue $ do
Nothing -> noop
Just started -> do
now <- liftIO getPOSIXTime
- when (now - realToFrac started >= delta)
+ when (now - realToFrac started >= durationToPOSIXTime delta)
resetStartTime
return True
diff --git a/Command/Status.hs b/Command/Status.hs
index e1ace0052..c3713f073 100644
--- a/Command/Status.hs
+++ b/Command/Status.hs
@@ -363,7 +363,7 @@ showSizeKeys d = total ++ missingnote
" keys of unknown size"
staleSize :: String -> (Git.Repo -> FilePath) -> Stat
-staleSize label dirspec = go =<< lift (Command.Unused.staleKeys dirspec)
+staleSize label dirspec = go =<< lift (dirKeys dirspec)
where
go [] = nostat
go keys = onsize =<< sum <$> keysizes keys
diff --git a/Command/Unused.hs b/Command/Unused.hs
index d49cda54b..6210b2115 100644
--- a/Command/Unused.hs
+++ b/Command/Unused.hs
@@ -304,7 +304,7 @@ withKeysReferencedInGitRef a ref = do
-}
staleKeysPrune :: (Git.Repo -> FilePath) -> Bool -> Annex [Key]
staleKeysPrune dirspec nottransferred = do
- contents <- staleKeys dirspec
+ contents <- dirKeys dirspec
dups <- filterM inAnnex contents
let stale = contents `exclude` dups
@@ -319,18 +319,6 @@ staleKeysPrune dirspec nottransferred = do
return $ filter (`S.notMember` inprogress) stale
else return stale
-staleKeys :: (Git.Repo -> FilePath) -> Annex [Key]
-staleKeys dirspec = do
- dir <- fromRepo dirspec
- ifM (liftIO $ doesDirectoryExist dir)
- ( do
- contents <- liftIO $ getDirectoryContents dir
- files <- liftIO $ filterM doesFileExist $
- map (dir </>) contents
- return $ mapMaybe (fileKey . takeFileName) files
- , return []
- )
-
data UnusedMaps = UnusedMaps
{ unusedMap :: UnusedMap
, unusedBadMap :: UnusedMap
diff --git a/Command/Vicfg.hs b/Command/Vicfg.hs
index dfdcde134..c6fc5ffc9 100644
--- a/Command/Vicfg.hs
+++ b/Command/Vicfg.hs
@@ -12,6 +12,7 @@ import qualified Data.Set as S
import System.Environment (getEnv)
import Data.Tuple (swap)
import Data.Char (isSpace)
+import Data.Either
import Common.Annex
import Command
@@ -21,7 +22,9 @@ import Types.Group
import Logs.Trust
import Logs.Group
import Logs.PreferredContent
+import Logs.Schedule
import Types.StandardGroups
+import Types.ScheduledActivity
import Remote
def :: [Command]
@@ -59,6 +62,7 @@ data Cfg = Cfg
{ cfgTrustMap :: TrustMap
, cfgGroupMap :: M.Map UUID (S.Set Group)
, cfgPreferredContentMap :: M.Map UUID String
+ , cfgScheduleMap :: M.Map UUID [ScheduledActivity]
}
getCfg :: Annex Cfg
@@ -66,22 +70,25 @@ getCfg = Cfg
<$> trustMapRaw -- without local trust overrides
<*> (groupsByUUID <$> groupMap)
<*> preferredContentMapRaw
+ <*> scheduleMap
setCfg :: Cfg -> Cfg -> Annex ()
setCfg curcfg newcfg = do
- let (trustchanges, groupchanges, preferredcontentchanges) = diffCfg curcfg newcfg
+ let (trustchanges, groupchanges, preferredcontentchanges, schedulechanges) = diffCfg curcfg newcfg
mapM_ (uncurry trustSet) $ M.toList trustchanges
mapM_ (uncurry groupSet) $ M.toList groupchanges
mapM_ (uncurry preferredContentSet) $ M.toList preferredcontentchanges
+ mapM_ (uncurry scheduleSet) $ M.toList schedulechanges
-diffCfg :: Cfg -> Cfg -> (TrustMap, M.Map UUID (S.Set Group), M.Map UUID String)
-diffCfg curcfg newcfg = (diff cfgTrustMap, diff cfgGroupMap, diff cfgPreferredContentMap)
+diffCfg :: Cfg -> Cfg -> (TrustMap, M.Map UUID (S.Set Group), M.Map UUID String, M.Map UUID [ScheduledActivity])
+diffCfg curcfg newcfg = (diff cfgTrustMap, diff cfgGroupMap, diff cfgPreferredContentMap, diff cfgScheduleMap)
where
diff f = M.differenceWith (\x y -> if x == y then Nothing else Just x)
(f newcfg) (f curcfg)
genCfg :: Cfg -> M.Map UUID String -> String
-genCfg cfg descs = unlines $ concat [intro, trust, groups, preferredcontent]
+genCfg cfg descs = unlines $ concat
+ [intro, trust, groups, preferredcontent, schedule]
where
intro =
[ com "git-annex configuration"
@@ -120,6 +127,14 @@ genCfg cfg descs = unlines $ concat [intro, trust, groups, preferredcontent]
(\(s, u) -> line "content" u s)
(\u -> line "content" u "")
+ schedule = settings cfgScheduleMap
+ [ ""
+ , com "Scheduled activities"
+ , com "(Separate multiple activities with \"; \")"
+ ]
+ (\(l, u) -> line "schedule" u $ intercalate "; " $ map fromScheduledActivity l)
+ (\u -> line "schedule" u "")
+
settings field desc showvals showdefaults = concat
[ desc
, concatMap showvals $ sort $ map swap $ M.toList $ field cfg
@@ -173,6 +188,14 @@ parseCfg curcfg = go [] curcfg . lines
Nothing ->
let m = M.insert u value (cfgPreferredContentMap cfg)
in Right $ cfg { cfgPreferredContentMap = m }
+ | setting == "schedule" =
+ let (bad, good) = partitionEithers $
+ map parseScheduledActivity $ split "; " value
+ in if null bad
+ then
+ let m = M.insert u good (cfgScheduleMap cfg)
+ in Right $ cfg { cfgScheduleMap = m }
+ else Left $ intercalate "; " bad
| otherwise = badval "setting" setting
showerr (Just msg, l) = [parseerr ++ msg, l]