Commit
+41 -32 +/-3 browse
1 | diff --git a/Cargo.lock b/Cargo.lock |
2 | index 978586a..be9955f 100644 |
3 | --- a/Cargo.lock |
4 | +++ b/Cargo.lock |
5 | @@ -1069,8 +1069,8 @@ dependencies = [ |
6 | "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", |
7 | "pretty_env_logger 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", |
8 | "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", |
9 | - "rusoto_core 0.37.0 (registry+https://github.com/rust-lang/crates.io-index)", |
10 | - "rusoto_s3 0.37.0 (registry+https://github.com/rust-lang/crates.io-index)", |
11 | + "rusoto_core 0.40.0 (registry+https://github.com/rust-lang/crates.io-index)", |
12 | + "rusoto_s3 0.40.0 (registry+https://github.com/rust-lang/crates.io-index)", |
13 | "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", |
14 | "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", |
15 | "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", |
16 | @@ -1082,21 +1082,25 @@ dependencies = [ |
17 | |
18 | [[package]] |
19 | name = "rusoto_core" |
20 | - version = "0.37.0" |
21 | + version = "0.40.0" |
22 | source = "registry+https://github.com/rust-lang/crates.io-index" |
23 | dependencies = [ |
24 | "base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", |
25 | + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", |
26 | "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", |
27 | "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", |
28 | "hmac 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", |
29 | + "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", |
30 | "hyper 0.12.31 (registry+https://github.com/rust-lang/crates.io-index)", |
31 | "hyper-rustls 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)", |
32 | "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", |
33 | "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", |
34 | "md5 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", |
35 | - "rusoto_credential 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", |
36 | + "rusoto_credential 0.40.0 (registry+https://github.com/rust-lang/crates.io-index)", |
37 | "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", |
38 | "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", |
39 | + "serde_derive 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", |
40 | + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", |
41 | "sha2 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", |
42 | "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", |
43 | "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", |
44 | @@ -1107,7 +1111,7 @@ dependencies = [ |
45 | |
46 | [[package]] |
47 | name = "rusoto_credential" |
48 | - version = "0.16.0" |
49 | + version = "0.40.0" |
50 | source = "registry+https://github.com/rust-lang/crates.io-index" |
51 | dependencies = [ |
52 | "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", |
53 | @@ -1125,11 +1129,12 @@ dependencies = [ |
54 | |
55 | [[package]] |
56 | name = "rusoto_s3" |
57 | - version = "0.37.0" |
58 | + version = "0.40.0" |
59 | source = "registry+https://github.com/rust-lang/crates.io-index" |
60 | dependencies = [ |
61 | + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", |
62 | "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", |
63 | - "rusoto_core 0.37.0 (registry+https://github.com/rust-lang/crates.io-index)", |
64 | + "rusoto_core 0.40.0 (registry+https://github.com/rust-lang/crates.io-index)", |
65 | "xml-rs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", |
66 | ] |
67 | |
68 | @@ -1943,9 +1948,9 @@ dependencies = [ |
69 | "checksum regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "d9d8297cc20bbb6184f8b45ff61c8ee6a9ac56c156cec8e38c3e5084773c44ad" |
70 | "checksum regex-syntax 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "9b01330cce219c1c6b2e209e5ed64ccd587ae5c67bed91c0b49eecf02ae40e21" |
71 | "checksum ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)" = "426bc186e3e95cac1e4a4be125a4aca7e84c2d616ffc02244eef36e2a60a093c" |
72 | - "checksum rusoto_core 0.37.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b03958c1f00c85d038f7c3532f33381cf3cda93e88ad745cc5dcdb3d9675bb6" |
73 | - "checksum rusoto_credential 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "00d75d9360c522cc29d80eaa5ecdd8fa56d811578118d6cf8ec083c035343baa" |
74 | - "checksum rusoto_s3 0.37.0 (registry+https://github.com/rust-lang/crates.io-index)" = "deec58d788a92ea7a5711815dba59e80e4f58b870707f3892e6904c0f9f07023" |
75 | + "checksum rusoto_core 0.40.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dd1a1069ba04874a485528d1602fab4569f2434a5547614428e2cc22b91bfb71" |
76 | + "checksum rusoto_credential 0.40.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b0d6cc3a602f01b9c5a04c8ed4ee281b789c5b2692d93202367c9b99ebc022ed" |
77 | + "checksum rusoto_s3 0.40.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4da6eac54781d2aac517a99f1d85d0d6a78674543f8d122d884628c1ff21b495" |
78 | "checksum rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f4dccf6f4891ebcc0c39f9b6eb1a83b9bf5d747cb439ec6fba4f3b977038af" |
79 | "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" |
80 | "checksum rustls 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f271e3552cd835fa28c541c34a7e8fdd8cdff09d77fe4eb8f6c42e87a11b096e" |
81 | diff --git a/Cargo.toml b/Cargo.toml |
82 | index 082adba..44467a0 100644 |
83 | --- a/Cargo.toml |
84 | +++ b/Cargo.toml |
85 | @@ -40,12 +40,12 @@ uuid = { version = "0.7", features = ["v4"] } |
86 | rand = { version = "0.6", optional = true } |
87 | |
88 | [dependencies.rusoto_core] |
89 | - version = "0.37" |
90 | + version = "0.40" |
91 | default_features = false |
92 | features = ["rustls"] |
93 | |
94 | [dependencies.rusoto_s3] |
95 | - version = "0.37" |
96 | + version = "0.40" |
97 | default_features = false |
98 | features = ["rustls"] |
99 | |
100 | diff --git a/src/storage/s3.rs b/src/storage/s3.rs |
101 | index e0f6fb8..79f718d 100644 |
102 | --- a/src/storage/s3.rs |
103 | +++ b/src/storage/s3.rs |
104 | @@ -21,7 +21,7 @@ use bytes::Bytes; |
105 | use derive_more::{Display, From}; |
106 | use futures::{future, stream, Future, Stream}; |
107 | use http::StatusCode; |
108 | - use rusoto_core::Region; |
109 | + use rusoto_core::{Region, RusotoError}; |
110 | use rusoto_s3::{ |
111 | GetObjectError, GetObjectRequest, HeadBucketError, HeadBucketRequest, |
112 | HeadObjectError, HeadObjectRequest, PutObjectError, PutObjectRequest, |
113 | @@ -32,9 +32,9 @@ use super::{LFSObject, Storage, StorageFuture, StorageKey, StorageStream}; |
114 | |
115 | #[derive(Debug, From, Display)] |
116 | pub enum Error { |
117 | - GetObjectError(GetObjectError), |
118 | - PutObjectError(PutObjectError), |
119 | - HeadObjectError(HeadObjectError), |
120 | + Get(RusotoError<GetObjectError>), |
121 | + Put(RusotoError<PutObjectError>), |
122 | + Head(RusotoError<HeadObjectError>), |
123 | |
124 | /// Initialization error. |
125 | Init(InitError), |
126 | @@ -54,22 +54,28 @@ pub enum InitError { |
127 | Credentials, |
128 | |
129 | #[display(fmt = "{}", _0)] |
130 | - Other(HeadBucketError), |
131 | + Other(String), |
132 | } |
133 | |
134 | - impl From<HeadBucketError> for InitError { |
135 | - fn from(err: HeadBucketError) -> Self { |
136 | + impl From<RusotoError<HeadBucketError>> for InitError { |
137 | + fn from(err: RusotoError<HeadBucketError>) -> Self { |
138 | match err { |
139 | - HeadBucketError::Unknown(r) => { |
140 | + RusotoError::Credentials(_) => InitError::Credentials, |
141 | + RusotoError::Unknown(r) => { |
142 | // Rusoto really sucks at correctly reporting errors. |
143 | // Lets work around that here. |
144 | match r.status { |
145 | StatusCode::NOT_FOUND => InitError::Bucket, |
146 | StatusCode::FORBIDDEN => InitError::Credentials, |
147 | - _ => InitError::Other(HeadBucketError::Unknown(r)), |
148 | + _ => { |
149 | + InitError::Other("S3 returned an unknown error".into()) |
150 | + } |
151 | } |
152 | } |
153 | - x => InitError::Other(x), |
154 | + RusotoError::Service(HeadBucketError::NoSuchBucket(_)) => { |
155 | + InitError::Bucket |
156 | + } |
157 | + x => InitError::Other(x.to_string()), |
158 | } |
159 | } |
160 | } |
161 | @@ -168,7 +174,10 @@ where |
162 | Box::new(object.body.unwrap().map(Bytes::from)), |
163 | ))), |
164 | Err(err) => { |
165 | - if let GetObjectError::NoSuchKey(_) = &err { |
166 | + if let RusotoError::Service( |
167 | + GetObjectError::NoSuchKey(_), |
168 | + ) = &err |
169 | + { |
170 | Ok(None) |
171 | } else { |
172 | Err(err) |
173 | @@ -186,13 +195,6 @@ where |
174 | ) -> StorageFuture<(), Self::Error> { |
175 | let (len, stream) = value.into_parts(); |
176 | |
177 | - let stream = stream.map(|chunk| { |
178 | - // Since Rusoto doesn't use a reference counted chunk of bytes, |
179 | - // we must copy to a new `Vec<u8>` here. See: |
180 | - // https://github.com/rusoto/rusoto/issues/1028 |
181 | - Vec::from(chunk.as_ref()) |
182 | - }); |
183 | - |
184 | let request = PutObjectRequest { |
185 | bucket: self.bucket.clone(), |
186 | key: self.key_to_path(&key), |
187 | @@ -223,7 +225,7 @@ where |
188 | } |
189 | Err(err) => { |
190 | match &err { |
191 | - HeadObjectError::Unknown(e) => { |
192 | + RusotoError::Unknown(e) => { |
193 | // There is a bug in Rusoto that causes it to |
194 | // always return an "unknown" error when the key |
195 | // does not exist. Thus we must check the error |
196 | @@ -235,7 +237,9 @@ where |
197 | Err(err) |
198 | } |
199 | } |
200 | - HeadObjectError::NoSuchKey(_) => Ok(None), |
201 | + RusotoError::Service( |
202 | + HeadObjectError::NoSuchKey(_), |
203 | + ) => Ok(None), |
204 | _ => Err(err), |
205 | } |
206 | } |