diff options
author | Jeremy Lin <[email protected]> | 2020-03-31 02:30:28 -0700 |
---|---|---|
committer | Jeremy Lin <[email protected]> | 2020-03-31 02:30:28 -0700 |
commit | 7407b8326aa02ca21c4c2dc1d98768fa8104412e (patch) | |
tree | f09eadd5f186cecd9cb79df03b0f8ce36e6c7e19 | |
parent | adf47827c98b09dc5cc0564f790f5f6c4a1906f8 (diff) | |
download | vaultwarden-7407b8326aa02ca21c4c2dc1d98768fa8104412e.tar.gz vaultwarden-7407b8326aa02ca21c4c2dc1d98768fa8104412e.zip |
Fix attachment size limit calculation
The config values (in KB) need to be converted to bytes when comparing
against total attachment sizes.
-rw-r--r-- | src/api/core/ciphers.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/api/core/ciphers.rs b/src/api/core/ciphers.rs index 8403a014..dcfd3f98 100644 --- a/src/api/core/ciphers.rs +++ b/src/api/core/ciphers.rs @@ -665,8 +665,8 @@ fn post_attachment( let size_limit = if let Some(ref user_uuid) = cipher.user_uuid { match CONFIG.user_attachment_limit() { Some(0) => err_discard!("Attachments are disabled", data), - Some(limit) => { - let left = limit - Attachment::size_by_user(user_uuid, &conn); + Some(limit_kb) => { + let left = (limit_kb * 1024) - Attachment::size_by_user(user_uuid, &conn); if left <= 0 { err_discard!("Attachment size limit reached! Delete some files to open space", data) } @@ -677,8 +677,8 @@ fn post_attachment( } else if let Some(ref org_uuid) = cipher.organization_uuid { match CONFIG.org_attachment_limit() { Some(0) => err_discard!("Attachments are disabled", data), - Some(limit) => { - let left = limit - Attachment::size_by_org(org_uuid, &conn); + Some(limit_kb) => { + let left = (limit_kb * 1024) - Attachment::size_by_org(org_uuid, &conn); if left <= 0 { err_discard!("Attachment size limit reached! Delete some files to open space", data) } |