fix(build): add some guards at calls to (%) for issue #34

This commit is contained in:
Steffen Jost 2022-06-07 17:49:00 +02:00
parent caa2278e32
commit d8d75edafe
3 changed files with 7 additions and 4 deletions

View File

@ -116,9 +116,10 @@ genMatch :: Int -- ^ Period
genMatch p m z st CronMatchAny = take p $ map (bool id (bool succ id z . (`mod` fromIntegral p) . bool pred id z) m) [st..]
genMatch _ _ _ _ CronMatchNone = []
genMatch p m z _ (CronMatchSome xs) = take p . map (bool id (bool succ id z . (`mod` fromIntegral p) . bool pred id z) m) . Set.toAscList $ toNullable xs
genMatch p m z st (CronMatchStep step) = do
genMatch p m z st (CronMatchStep step) = do
guard $ step /= 0
start <- [st..st + step]
guard $ (start `mod` step) == 0
guard $ (start `mod` step) == 0
take (ceiling $ fromIntegral p % step) $ map (bool id (bool succ id z . (`mod` fromIntegral p) . bool pred id z) m) [start,start + step..]
genMatch p m z st (CronMatchContiguous from to) = take p . map (bool id (bool succ id z . (`mod` fromIntegral p) . bool pred id z) m) $ [max st from..to]
genMatch _ _ _ _ (CronMatchIntersect CronMatchNone _) = []

View File

@ -275,7 +275,7 @@ dispatchJobInjectFiles = JobHandlerException . maybeT_ $ do
-> Handler (Sum Natural, Sum Word64)
injectOrDelete (objInfo, fRef) = do
let obj = Minio.oiObject objInfo
sz = fromIntegral $ Minio.oiSize objInfo
sz = fromIntegral $ max 1 $ Minio.oiSize objInfo
fRef' <- runDB $ do
logger <- askLoggerIO

View File

@ -119,7 +119,9 @@ dispatchHealthCheckLDAPAdmins = fmap HealthLDAPAdmins . yesodTimeout (^. _appHea
let hCampusExc :: CampusUserException -> Handler (Sum Integer)
hCampusExc err = mempty <$ $logErrorS "healthCheckLDAPAdmins" (adminIdent <> ": " <> tshow err)
in handle hCampusExc $ Sum 1 <$ campusUserReTest ldapPool ((>= reTestAfter) . realToFrac) FailoverUnlimited (Creds apLdap adminIdent [])
return $ numResolved % numAdmins
if numAdmins == 0
then return 0
else return $ numResolved % numAdmins
_other -> return Nothing