Better handle upload errors

This commit is contained in:
asonix 2020-06-13 14:04:33 -05:00
parent b3819b5caf
commit 53345823bb
3 changed files with 23 additions and 19 deletions

38
Cargo.lock generated
View file

@ -40,7 +40,7 @@ dependencies = [
[[package]]
name = "actix-form-data"
version = "0.5.0-alpha.0"
source = "git+https://git.asonix.dog/Aardwolf/actix-form-data#6985ce5e866f70703d20584aeedd9663e272f552"
source = "git+https://git.asonix.dog/Aardwolf/actix-form-data#070c4a4d4ae886bdd84a305f8ac57457136ae321"
dependencies = [
"actix-http",
"actix-multipart",
@ -470,7 +470,7 @@ dependencies = [
"block-padding",
"byte-tools",
"byteorder",
"generic-array 0.14.1",
"generic-array 0.14.2",
]
[[package]]
@ -626,12 +626,13 @@ dependencies = [
[[package]]
name = "crossbeam-queue"
version = "0.2.2"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab6bffe714b6bb07e42f201352c34f51fefd355ace793f9e638ebd52d23f98d2"
checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570"
dependencies = [
"cfg-if",
"crossbeam-utils",
"maybe-uninit",
]
[[package]]
@ -681,7 +682,7 @@ version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066"
dependencies = [
"generic-array 0.14.1",
"generic-array 0.14.2",
]
[[package]]
@ -901,11 +902,12 @@ dependencies = [
[[package]]
name = "generic-array"
version = "0.14.1"
version = "0.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d2664c2cf08049036f31015b04c6ac3671379a1d86f52ed2416893f16022deb"
checksum = "ac746a5f3bbfdadd6106868134545e684693d54d9d44f6e9588a7d54af0bf980"
dependencies = [
"typenum",
"version_check",
]
[[package]]
@ -1272,9 +1274,9 @@ dependencies = [
[[package]]
name = "num-integer"
version = "0.1.42"
version = "0.1.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f6ea62e9d81a77cd3ee9a2a5b9b609447857f3d358704331e4ef39eb247fcba"
checksum = "8d59457e662d541ba17869cf51cf177c0b5f0cbf476c66bdc90bf1edac4f875b"
dependencies = [
"autocfg",
"num-traits",
@ -1282,9 +1284,9 @@ dependencies = [
[[package]]
name = "num-iter"
version = "0.1.40"
version = "0.1.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dfb0800a0291891dd9f4fe7bd9c19384f98f7fbe0cd0f39a2c6b88b9868bbc00"
checksum = "7a6e6b7c748f995c4c29c5f5ae0248536e04a5739927c74ec0fa564805094b9f"
dependencies = [
"autocfg",
"num-integer",
@ -1304,9 +1306,9 @@ dependencies = [
[[package]]
name = "num-traits"
version = "0.2.11"
version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096"
checksum = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611"
dependencies = [
"autocfg",
]
@ -1371,7 +1373,7 @@ checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
[[package]]
name = "pict-rs"
version = "0.1.4"
version = "0.1.5"
dependencies = [
"actix-form-data",
"actix-fs",
@ -1396,18 +1398,18 @@ dependencies = [
[[package]]
name = "pin-project"
version = "0.4.20"
version = "0.4.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e75373ff9037d112bb19bc61333a06a159eaeb217660dcfbea7d88e1db823919"
checksum = "b044170ce52ac41b78bdf855a045f6fe6ba72c293a33a2e3f654642127680563"
dependencies = [
"pin-project-internal",
]
[[package]]
name = "pin-project-internal"
version = "0.4.20"
version = "0.4.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10b4b44893d3c370407a1d6a5cfde7c41ae0478e31c516c85f67eb3adc51be6d"
checksum = "babd76ce3c0d7c677fd01a3c3f9be24fa760adb73fd6db48f151662c1ec7eaba"
dependencies = [
"proc-macro2",
"quote",

View file

@ -1,7 +1,7 @@
[package]
name = "pict-rs"
description = "A simple image hosting service"
version = "0.1.4"
version = "0.1.5"
authors = ["asonix <asonix@asonix.dog>"]
license = "AGPL-3.0"
readme = "README.md"

View file

@ -265,6 +265,7 @@ async fn main() -> Result<(), anyhow::Error> {
let form = Form::new()
.max_files(10)
.max_file_size(config.max_file_size() * MEGABYTES)
.transform_error(|e| UploadError::from(e).into())
.field(
"images",
Field::array(Field::file(move |_, _, stream| {
@ -288,6 +289,7 @@ async fn main() -> Result<(), anyhow::Error> {
let import_form = Form::new()
.max_files(10)
.max_file_size(config.max_file_size() * MEGABYTES)
.transform_error(|e| UploadError::from(e).into())
.field(
"images",
Field::array(Field::file(move |filename, content_type, stream| {