This commit is contained in:
Steffen Jost 2019-05-09 15:54:32 +02:00
parent be7ae9c979
commit b0d23bca79
4 changed files with 28 additions and 5 deletions

View File

@ -29,7 +29,7 @@ notification-expiration: 259201
session-timeout: 7200 session-timeout: 7200
jwt-expiration: 604800 jwt-expiration: 604800
jwt-encoding: HS256 jwt-encoding: HS256
maximum-content-length: 52428800 maximum-content-length: 134217728
health-check-interval: "_env:HEALTHCHECK_INTERVAL:600" # or WATCHDOG_USEC/2, whichever is smaller health-check-interval: "_env:HEALTHCHECK_INTERVAL:600" # or WATCHDOG_USEC/2, whichever is smaller
health-check-http: "_env:HEALTHCHECK_HTTP:true" health-check-http: "_env:HEALTHCHECK_HTTP:true"
health-check-delay-notify: "_env:HEALTHCHECK_DELAY_NOTIFY:true" health-check-delay-notify: "_env:HEALTHCHECK_DELAY_NOTIFY:true"

View File

@ -721,6 +721,7 @@ postCorrectionsUploadR = do
, formEncoding = uploadEncoding , formEncoding = uploadEncoding
} }
maxUploadMB <- appMaximumContentLength <$> getsYesod appSettings'
defaultLayout $ do defaultLayout $ do
let uploadInstruction = $(i18nWidgetFile "corrections-upload-instructions") let uploadInstruction = $(i18nWidgetFile "corrections-upload-instructions")

View File

@ -262,6 +262,22 @@ textPercent x = lz <> pack (show rx) <> "%"
textPercentInt :: Integral a => a -> a -> Text -- slow, maybe use Data.Double.Conversion.Text.toFixed instead? textPercentInt :: Integral a => a -> a -> Text -- slow, maybe use Data.Double.Conversion.Text.toFixed instead?
textPercentInt part whole = textPercent $ fromIntegral part % fromIntegral whole textPercentInt part whole = textPercent $ fromIntegral part % fromIntegral whole
-- | Convert number of bytes to human readable format
textBytes :: Integral a => a -> Text
textBytes x
| v < kb = rshow v <> "B"
| v < mb = rshow (v/kb) <> "KB"
| v < gb = rshow (v/mb) <> "MB"
| otherwise = rshow (v/gb) <> "GB"
where
v = fromIntegral x
kb = 1024
mb = 1024 * kb
gb = 1024 * mb
rshow :: Double -> Text
rshow = tshow . floorToDigits 1
stepTextCounterCI :: CI Text -> CI Text -- find and increment rightmost-number, preserving leading zeroes stepTextCounterCI :: CI Text -> CI Text -- find and increment rightmost-number, preserving leading zeroes
stepTextCounterCI = CI.map stepTextCounter stepTextCounterCI = CI.map stepTextCounter
@ -294,6 +310,13 @@ notUsedT = notUsed
roundToNearestMultiple :: Int -> Int -> Int roundToNearestMultiple :: Int -> Int -> Int
roundToNearestMultiple m n = (n `div` m + 1) * m roundToNearestMultiple m n = (n `div` m + 1) * m
roundToDigits :: (RealFrac a, Integral b) => b -> a -> a
roundToDigits d x = fromInteger (round $ x * prec) / prec
where prec = 10^d
floorToDigits :: (RealFrac a, Integral b) => b -> a -> a
floorToDigits d x = fromInteger (floor $ x * prec) / prec
where prec = 10^d

View File

@ -21,7 +21,6 @@
Korrekturen des letzten Korrektors gelöscht werden, falls diese den Abgabenden Korrekturen des letzten Korrektors gelöscht werden, falls diese den Abgabenden
nicht zur Verfügung gestellt werden sollen. nicht zur Verfügung gestellt werden sollen.
<section> $maybe maxUpload <- maxUploadMB
<p> <p>
<em>Achtung: Das Limit für die Dateigröße beträgt momentan #{textBytes maxUpload}
Das Limit für die Dateigröße beträgt momentan ungefähr 52MB