Merge scheduler bug fix from git-annex.
This commit is contained in:
parent
be01532282
commit
99ec97db85
|
@ -108,65 +108,65 @@ calcNextTime (Schedule recurrance scheduledtime) lasttime currenttime
|
|||
window startd endd = NextTimeWindow
|
||||
(LocalTime startd nexttime)
|
||||
(LocalTime endd (TimeOfDay 23 59 0))
|
||||
findfrom r afterday day = case r of
|
||||
findfrom r afterday candidate = case r of
|
||||
Daily
|
||||
| afterday -> Just $ exactly $ addDays 1 day
|
||||
| otherwise -> Just $ exactly day
|
||||
| afterday -> Just $ exactly $ addDays 1 candidate
|
||||
| otherwise -> Just $ exactly candidate
|
||||
Weekly Nothing
|
||||
| afterday -> skip 1
|
||||
| otherwise -> case (wday <$> lastday, wday day) of
|
||||
(Nothing, _) -> Just $ window day (addDays 6 day)
|
||||
| otherwise -> case (wday <$> lastday, wday candidate) of
|
||||
(Nothing, _) -> Just $ window candidate (addDays 6 candidate)
|
||||
(Just old, curr)
|
||||
| old == curr -> Just $ window day (addDays 6 day)
|
||||
| old == curr -> Just $ window candidate (addDays 6 candidate)
|
||||
| otherwise -> skip 1
|
||||
Monthly Nothing
|
||||
| afterday -> skip 1
|
||||
| maybe True (\old -> mnum day > mday old && mday day >= (mday old `mod` minmday)) lastday ->
|
||||
| maybe True (\old -> mnum candidate > mnum old && mday candidate >= (mday old `mod` minmday)) lastday ->
|
||||
-- Window only covers current month,
|
||||
-- in case there is a Divisible requirement.
|
||||
Just $ window day (endOfMonth day)
|
||||
Just $ window candidate (endOfMonth candidate)
|
||||
| otherwise -> skip 1
|
||||
Yearly Nothing
|
||||
| afterday -> skip 1
|
||||
| maybe True (\old -> ynum day > ynum old && yday day >= (yday old `mod` minyday)) lastday ->
|
||||
Just $ window day (endOfYear day)
|
||||
| maybe True (\old -> ynum candidate > ynum old && yday candidate >= (yday old `mod` minyday)) lastday ->
|
||||
Just $ window candidate (endOfYear candidate)
|
||||
| otherwise -> skip 1
|
||||
Weekly (Just w)
|
||||
| w < 0 || w > maxwday -> Nothing
|
||||
| w == wday day -> if afterday
|
||||
then Just $ exactly $ addDays 7 day
|
||||
else Just $ exactly day
|
||||
| w == wday candidate -> if afterday
|
||||
then Just $ exactly $ addDays 7 candidate
|
||||
else Just $ exactly candidate
|
||||
| otherwise -> Just $ exactly $
|
||||
addDays (fromIntegral $ (w - wday day) `mod` 7) day
|
||||
addDays (fromIntegral $ (w - wday candidate) `mod` 7) candidate
|
||||
Monthly (Just m)
|
||||
| m < 0 || m > maxmday -> Nothing
|
||||
-- TODO can be done more efficiently than recursing
|
||||
| m == mday day -> if afterday
|
||||
| m == mday candidate -> if afterday
|
||||
then skip 1
|
||||
else Just $ exactly day
|
||||
else Just $ exactly candidate
|
||||
| otherwise -> skip 1
|
||||
Yearly (Just y)
|
||||
| y < 0 || y > maxyday -> Nothing
|
||||
| y == yday day -> if afterday
|
||||
| y == yday candidate -> if afterday
|
||||
then skip 365
|
||||
else Just $ exactly day
|
||||
else Just $ exactly candidate
|
||||
| otherwise -> skip 1
|
||||
Divisible n r'@Daily -> handlediv n r' yday (Just maxyday)
|
||||
Divisible n r'@(Weekly _) -> handlediv n r' wnum (Just maxwnum)
|
||||
Divisible n r'@(Monthly _) -> handlediv n r' mnum (Just maxmnum)
|
||||
Divisible n r'@(Yearly _) -> handlediv n r' ynum Nothing
|
||||
Divisible _ r'@(Divisible _ _) -> findfrom r' afterday day
|
||||
Divisible _ r'@(Divisible _ _) -> findfrom r' afterday candidate
|
||||
where
|
||||
skip n = findfrom r False (addDays n day)
|
||||
skip n = findfrom r False (addDays n candidate)
|
||||
handlediv n r' getval mmax
|
||||
| n > 0 && maybe True (n <=) mmax =
|
||||
findfromwhere r' (divisible n . getval) afterday day
|
||||
findfromwhere r' (divisible n . getval) afterday candidate
|
||||
| otherwise = Nothing
|
||||
findfromwhere r p afterday day
|
||||
findfromwhere r p afterday candidate
|
||||
| maybe True (p . getday) next = next
|
||||
| otherwise = maybe Nothing (findfromwhere r p True . getday) next
|
||||
where
|
||||
next = findfrom r afterday day
|
||||
next = findfrom r afterday candidate
|
||||
getday = localDay . startTime
|
||||
divisible n v = v `rem` n == 0
|
||||
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
propellor (0.3.1) UNRELEASED; urgency=medium
|
||||
|
||||
* Merge scheduler bug fix from git-annex.
|
||||
|
||||
-- Joey Hess <joeyh@debian.org> Fri, 11 Apr 2014 15:00:11 -0400
|
||||
|
||||
propellor (0.3.0) unstable; urgency=medium
|
||||
|
||||
* ipv6to4: Ensure interface is brought up automatically on boot.
|
||||
|
|
Loading…
Reference in New Issue