geforkt von mirrored/vaultwarden
Fix attachment size limit calculation
The config values (in KB) need to be converted to bytes when comparing against total attachment sizes.
Dieser Commit ist enthalten in:
Ursprung
adf47827c9
Commit
7407b8326a
1 geänderte Dateien mit 4 neuen und 4 gelöschten Zeilen
|
@ -665,8 +665,8 @@ fn post_attachment(
|
||||||
let size_limit = if let Some(ref user_uuid) = cipher.user_uuid {
|
let size_limit = if let Some(ref user_uuid) = cipher.user_uuid {
|
||||||
match CONFIG.user_attachment_limit() {
|
match CONFIG.user_attachment_limit() {
|
||||||
Some(0) => err_discard!("Attachments are disabled", data),
|
Some(0) => err_discard!("Attachments are disabled", data),
|
||||||
Some(limit) => {
|
Some(limit_kb) => {
|
||||||
let left = limit - Attachment::size_by_user(user_uuid, &conn);
|
let left = (limit_kb * 1024) - Attachment::size_by_user(user_uuid, &conn);
|
||||||
if left <= 0 {
|
if left <= 0 {
|
||||||
err_discard!("Attachment size limit reached! Delete some files to open space", data)
|
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 {
|
} else if let Some(ref org_uuid) = cipher.organization_uuid {
|
||||||
match CONFIG.org_attachment_limit() {
|
match CONFIG.org_attachment_limit() {
|
||||||
Some(0) => err_discard!("Attachments are disabled", data),
|
Some(0) => err_discard!("Attachments are disabled", data),
|
||||||
Some(limit) => {
|
Some(limit_kb) => {
|
||||||
let left = limit - Attachment::size_by_org(org_uuid, &conn);
|
let left = (limit_kb * 1024) - Attachment::size_by_org(org_uuid, &conn);
|
||||||
if left <= 0 {
|
if left <= 0 {
|
||||||
err_discard!("Attachment size limit reached! Delete some files to open space", data)
|
err_discard!("Attachment size limit reached! Delete some files to open space", data)
|
||||||
}
|
}
|
||||||
|
|
Laden …
In neuem Issue referenzieren