fix code style for clippy

This commit is contained in:
Alek Westover
2023-06-22 09:37:07 -04:00
parent 94781e8710
commit bf3b83b504
4 changed files with 18 additions and 17 deletions

View File

@@ -73,7 +73,7 @@ fn main() -> Result<()> {
let rt = Runtime::new().unwrap();
let copy_remote_storage = remote_storage.clone();
rt.block_on(async move {
download_extension(&copy_remote_storage, ExtensionType::Shared, &pgbin)
download_extension(&copy_remote_storage, ExtensionType::Shared, pgbin)
.await
.expect("download extension should work");
});
@@ -192,7 +192,7 @@ fn main() -> Result<()> {
live_config_allowed,
state: Mutex::new(new_state),
state_changed: Condvar::new(),
remote_storage: remote_storage,
remote_storage,
};
let compute = Arc::new(compute_node);

View File

@@ -47,14 +47,14 @@ async fn download_helper(
"Downloading {:?} to location {:?}",
&remote_from_path, &file_name
);
let mut download = remote_storage.download(&remote_from_path).await?;
let mut download = remote_storage.download(remote_from_path).await?;
let mut write_data_buffer = Vec::new();
download
.download_stream
.read_to_end(&mut write_data_buffer)
.await?;
let mut output_file = BufWriter::new(File::create(file_name)?);
output_file.write_all(&mut write_data_buffer)?;
output_file.write_all(&write_data_buffer)?;
Ok(())
}
@@ -81,18 +81,18 @@ pub async fn download_extension(
let from_paths = remote_storage.list_files(Some(&folder)).await?;
for remote_from_path in from_paths {
if remote_from_path.extension() == Some("control") {
download_helper(&remote_storage, &remote_from_path).await?;
download_helper(remote_storage, &remote_from_path).await?;
}
}
}
ExtensionType::Tenant(tenant_id) => {
// 2. After we have spec, before project start
// Download control files from s3-bucket/[tenant-id]/*.control to SHAREDIR/extension
let folder = RemotePath::new(Path::new(&format!("{tenant_id}")))?;
let folder = RemotePath::new(Path::new(&tenant_id.to_string()))?;
let from_paths = remote_storage.list_files(Some(&folder)).await?;
for remote_from_path in from_paths {
if remote_from_path.extension() == Some("control") {
download_helper(&remote_storage, &remote_from_path).await?;
download_helper(remote_storage, &remote_from_path).await?;
}
}
}
@@ -101,7 +101,7 @@ pub async fn download_extension(
// Download preload_shared_libraries from s3-bucket/public/[library-name].control into LIBDIR/
let from_path = format!("neon-dev-extensions/public/{library_name}.control");
let remote_from_path = RemotePath::new(Path::new(&from_path))?;
download_helper(&remote_storage, &remote_from_path).await?;
download_helper(remote_storage, &remote_from_path).await?;
}
}
Ok(())
@@ -140,5 +140,5 @@ pub fn init_remote_storage(remote_ext_config: &str) -> anyhow::Result<GenericRem
max_sync_errors: NonZeroU32::new(100).expect("100 != 0"),
storage: RemoteStorageKind::AwsS3(config),
};
Ok(GenericRemoteStorage::from_config(&config)?)
GenericRemoteStorage::from_config(&config)
}

View File

@@ -127,7 +127,7 @@ async fn routes(req: Request<Body>, compute: &Arc<ComputeNode>) -> Response<Body
(&Method::POST, route) if route.starts_with("/extension_server/") => {
info!("serving {:?} POST request", route);
let filename = route.split("/").last().unwrap();
let filename = route.split('/').last().unwrap();
info!(
"serving /extension_server POST request, filename: {:?}",

View File

@@ -1,11 +1,12 @@
import json
import os
from contextlib import closing
from fixtures.log_helper import log
from fixtures.neon_fixtures import (
NeonEnvBuilder,
RemoteStorageKind,
)
import json
import os
def test_file_download(neon_env_builder: NeonEnvBuilder):
@@ -39,11 +40,11 @@ def test_file_download(neon_env_builder: NeonEnvBuilder):
# 5. Download file from the bucket to correct local location
# Later this will be replaced by our rust code
resp = env.remote_storage_client.get_object(
Bucket=env.ext_remote_storage.bucket_name, Key=os.path.join(BUCKET_PREFIX, TEST_EXT_PATH)
)
response = resp["Body"]
fname = f"pg_install/{TEST_EXT_PATH}"
# resp = env.remote_storage_client.get_object(
# Bucket=env.ext_remote_storage.bucket_name, Key=os.path.join(BUCKET_PREFIX, TEST_EXT_PATH)
# )
# response = resp["Body"]
# fname = f"pg_install/{TEST_EXT_PATH}"
# with open(fname, "wb") as f:
# f.write(response.read())