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

@ -117,6 +117,7 @@ genMatch p m z st CronMatchAny = take p $ map (bool id (bool succ id z . (`mod`
genMatch _ _ _ _ CronMatchNone = [] 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 _ (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] 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..] take (ceiling $ fromIntegral p % step) $ map (bool id (bool succ id z . (`mod` fromIntegral p) . bool pred id z) m) [start,start + step..]

View File

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

View File

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