Skip to content

Commit 426e6e3

Browse files
KixironJoshua Nelson
authored and
Joshua Nelson
committed
Stop requiring S3Backend
1 parent 3bc906e commit 426e6e3

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/db/delete.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use crate::storage::s3::{s3_client, S3Backend, S3_BUCKET_NAME, S3_RUNTIME};
1+
use crate::storage::s3::{s3_client, S3_BUCKET_NAME, S3_RUNTIME};
22
use failure::{Error, Fail};
33
use postgres::Connection;
4-
use rusoto_s3::{DeleteObjectsRequest, ListObjectsV2Request, ObjectIdentifier, S3};
4+
use rusoto_s3::{DeleteObjectsRequest, ListObjectsV2Request, ObjectIdentifier, S3Client, S3};
55

66
/// List of directories in docs.rs's underlying storage (either the database or S3) containing a
77
/// subdirectory named after the crate. Those subdirectories will be deleted.
@@ -17,7 +17,7 @@ pub fn delete_crate(conn: &Connection, name: &str) -> Result<(), Error> {
1717
let crate_id = get_id(conn, name)?;
1818
delete_crate_from_database(conn, name, crate_id)?;
1919

20-
if let Some(backend) = s3_client().map(|client| S3Backend::new(client, S3_BUCKET_NAME)) {
20+
if let Some(backend) = s3_client() {
2121
for prefix in STORAGE_PATHS_TO_DELETE {
2222
delete_prefix_from_s3(&backend, &format!("{}/{}/", prefix, name))?;
2323
}
@@ -29,7 +29,7 @@ pub fn delete_crate(conn: &Connection, name: &str) -> Result<(), Error> {
2929
pub fn delete_version(conn: &Connection, name: &str, version: &str) -> Result<(), Error> {
3030
delete_version_from_database(conn, name, version)?;
3131

32-
if let Some(backend) = s3_client().map(|client| S3Backend::new(client, S3_BUCKET_NAME)) {
32+
if let Some(backend) = s3_client() {
3333
for prefix in STORAGE_PATHS_TO_DELETE {
3434
delete_prefix_from_s3(&backend, &format!("{}/{}/{}/", prefix, name, version))?;
3535
}
@@ -121,12 +121,11 @@ fn delete_crate_from_database(conn: &Connection, name: &str, crate_id: i32) -> R
121121
Ok(())
122122
}
123123

124-
fn delete_prefix_from_s3(s3: &S3Backend, name: &str) -> Result<(), Error> {
124+
fn delete_prefix_from_s3(s3: &S3Client, name: &str) -> Result<(), Error> {
125125
S3_RUNTIME.handle().block_on(async {
126126
let mut continuation_token = None;
127127
loop {
128128
let list = s3
129-
.client
130129
.list_objects_v2(ListObjectsV2Request {
131130
bucket: S3_BUCKET_NAME.into(),
132131
prefix: Some(name.into()),
@@ -147,7 +146,6 @@ fn delete_prefix_from_s3(s3: &S3Backend, name: &str) -> Result<(), Error> {
147146
.collect::<Vec<_>>();
148147

149148
let resp = s3
150-
.client
151149
.delete_objects(DeleteObjectsRequest {
152150
bucket: S3_BUCKET_NAME.into(),
153151
delete: rusoto_s3::Delete {

0 commit comments

Comments
 (0)