expire --no-act
This commit is contained in:
parent
e3ea9d21fc
commit
62ed5409c6
2 changed files with 17 additions and 6 deletions
|
@ -21,7 +21,7 @@ import Data.Time.Clock.POSIX
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
|
|
||||||
cmd :: [Command]
|
cmd :: [Command]
|
||||||
cmd = [withOptions [activityOption] $ command "expire" paramExpire seek
|
cmd = [withOptions [activityOption, noActOption] $ command "expire" paramExpire seek
|
||||||
SectionMaintenance "expire inactive repositories"]
|
SectionMaintenance "expire inactive repositories"]
|
||||||
|
|
||||||
paramExpire :: String
|
paramExpire :: String
|
||||||
|
@ -30,27 +30,33 @@ paramExpire = (paramRepeating $ paramOptional paramRemote ++ ":" ++ paramTime)
|
||||||
activityOption :: Option
|
activityOption :: Option
|
||||||
activityOption = fieldOption [] "activity" "Name" "specify activity"
|
activityOption = fieldOption [] "activity" "Name" "specify activity"
|
||||||
|
|
||||||
|
noActOption :: Option
|
||||||
|
noActOption = flagOption [] "no-act" "don't really do anything"
|
||||||
|
|
||||||
seek :: CommandSeek
|
seek :: CommandSeek
|
||||||
seek ps = do
|
seek ps = do
|
||||||
expire <- parseExpire ps
|
expire <- parseExpire ps
|
||||||
wantact <- getOptionField activityOption (pure . parseActivity)
|
wantact <- getOptionField activityOption (pure . parseActivity)
|
||||||
|
noact <- getOptionFlag noActOption
|
||||||
actlog <- lastActivities wantact
|
actlog <- lastActivities wantact
|
||||||
u <- getUUID
|
u <- getUUID
|
||||||
us <- filter (/= u) . M.keys <$> uuidMap
|
us <- filter (/= u) . M.keys <$> uuidMap
|
||||||
descs <- uuidMap
|
descs <- uuidMap
|
||||||
seekActions $ pure $ map (start expire actlog descs) us
|
seekActions $ pure $ map (start expire noact actlog descs) us
|
||||||
|
|
||||||
start :: Expire -> Log Activity -> M.Map UUID String -> UUID -> CommandStart
|
start :: Expire -> Bool -> Log Activity -> M.Map UUID String -> UUID -> CommandStart
|
||||||
start (Expire expire) actlog descs u =
|
start (Expire expire) noact actlog descs u =
|
||||||
case lastact of
|
case lastact of
|
||||||
Just ent | notexpired ent -> checktrust (== DeadTrusted) $ do
|
Just ent | notexpired ent -> checktrust (== DeadTrusted) $ do
|
||||||
showStart "unexpire" desc
|
showStart "unexpire" desc
|
||||||
showNote =<< whenactive
|
showNote =<< whenactive
|
||||||
trustSet u SemiTrusted
|
unless noact $
|
||||||
|
trustSet u SemiTrusted
|
||||||
_ -> checktrust (/= DeadTrusted) $ do
|
_ -> checktrust (/= DeadTrusted) $ do
|
||||||
showStart "expire" desc
|
showStart "expire" desc
|
||||||
showNote =<< whenactive
|
showNote =<< whenactive
|
||||||
trustSet u DeadTrusted
|
unless noact $
|
||||||
|
trustSet u DeadTrusted
|
||||||
where
|
where
|
||||||
lastact = changed <$> M.lookup u actlog
|
lastact = changed <$> M.lookup u actlog
|
||||||
whenactive = case lastact of
|
whenactive = case lastact of
|
||||||
|
|
|
@ -30,6 +30,11 @@ expired.
|
||||||
|
|
||||||
# OPTIONS
|
# OPTIONS
|
||||||
|
|
||||||
|
* `--no-act`
|
||||||
|
|
||||||
|
Print out what would be done, but not not actually expite or unexpire
|
||||||
|
any repositories.
|
||||||
|
|
||||||
* `--activity=Name`
|
* `--activity=Name`
|
||||||
|
|
||||||
Specify the activity that a repository must have performed to avoid being
|
Specify the activity that a repository must have performed to avoid being
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue