| 235 | #[async_trait(?Send)] |
| 236 | impl Drive for WebDrive { |
| 237 | async fn delete(&mut self, name: &str) -> io::Result<()> { |
| 238 | let key = Key::for_name(name); |
| 239 | let key = key.serialized(); |
| 240 | |
| 241 | match self.storage.get(key) { |
| 242 | Ok(Some(_)) => (), // File exists. |
| 243 | Ok(None) => return Err(io::Error::new(io::ErrorKind::NotFound, "File not found")), |
| 244 | Err(_) => (), // Fall through to try deletion anyway. |
| 245 | } |
| 246 | |
| 247 | match self.storage.delete(key) { |
| 248 | Ok(()) => Ok(()), |
| 249 | Err(e) => Err(io::Error::other(format!( |
| 250 | "Failed to put remove storage entry with key {}: {:?}", |
| 251 | key, e |
| 252 | ))), |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | async fn enumerate(&self) -> io::Result<DriveFiles> { |
| 257 | let mut entries = BTreeMap::new(); |