mirror of
https://github.com/neondatabase/neon.git
synced 2026-10-15 16:22:57 +00:00
looking a lot better
This commit is contained in:
@@ -1,5 +0,0 @@
|
||||
this
|
||||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
|
||||
|
||||
lol
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
this
|
||||
ax mod p < p/2
|
||||
|
||||
its gonna be big!
|
||||
coming soon at 4pm
|
||||
lol
|
||||
|
||||
+15
-21
@@ -1,9 +1,7 @@
|
||||
/*
|
||||
**WIP**
|
||||
* This is a MWE of using our RemoteStorage API to call the aws stuff and download multiple files
|
||||
* TODO:
|
||||
* 2. s3_bucket needs a lot of work; for example to make sure the pagination thing goes fine.
|
||||
* 3. figure out how to write directly from the buffer to a local file; and just generally clean up main.rs
|
||||
* TODO: s3_bucket some work; for example to make sure the pagination thing goes fine.
|
||||
*/
|
||||
|
||||
use remote_storage::*;
|
||||
@@ -22,36 +20,32 @@ async fn main() -> anyhow::Result<()> {
|
||||
tracing::subscriber::set_global_default(subscriber)?;
|
||||
|
||||
let cfg_file_path = Path::new("./../.neon/pageserver.toml");
|
||||
let cfg_file_contents = std::fs::read_to_string(cfg_file_path).unwrap();
|
||||
let cfg_file_contents = std::fs::read_to_string(cfg_file_path)
|
||||
.with_context(|| format!( "Failed to read pageserver config at '{}'", cfg_file_path.display()))?;
|
||||
let toml = cfg_file_contents
|
||||
.parse::<toml_edit::Document>()
|
||||
.context("Error parsing toml")?;
|
||||
.with_context(|| format!( "Failed to parse '{}' as pageserver config", cfg_file_path.display()))?;
|
||||
let remote_storage_data = toml.get("remote_storage")
|
||||
.expect("field should be present");
|
||||
let remote_storage_config = RemoteStorageConfig::from_toml(remote_storage_data)
|
||||
.expect("error parsing toml")
|
||||
.expect("error parsing toml");
|
||||
.context("field should be present")?;
|
||||
let remote_storage_config = RemoteStorageConfig::from_toml(remote_storage_data)?
|
||||
.context("error configuring remote storage")?;
|
||||
info!("{:?}", remote_storage_config);
|
||||
let remote_storage = GenericRemoteStorage::from_config(&remote_storage_config)?;
|
||||
|
||||
let folder = RemotePath::new(Path::new("public_extensions"))?;
|
||||
let from_paths = remote_storage.list_files(Some(&folder)).await?;
|
||||
|
||||
let mut i = 0;
|
||||
for remote_from_path in from_paths {
|
||||
i += 1;
|
||||
println!("number {i}{:?}", remote_from_path.object_name());
|
||||
// TODO: is it giving the right name?
|
||||
// TODO: where should we actually save the files to?
|
||||
if remote_from_path.extension() == Some("control") {
|
||||
let mut data = remote_storage.download(&remote_from_path).await?;
|
||||
// write `data` to a file locally
|
||||
// TODO: I think that the way I'm doing this is not optimal;
|
||||
// It should be possible to write the data directly to a file
|
||||
// rather than first writing it to a vector...
|
||||
let file_name = remote_from_path.object_name().expect("it must exist");
|
||||
println!("{:?}",file_name);
|
||||
let mut download = remote_storage.download(&remote_from_path).await?;
|
||||
let mut write_data_buffer = Vec::new();
|
||||
data.download_stream.read_to_end(&mut write_data_buffer).await?;
|
||||
let f = File::create(format!("alek{i}.out")).expect("problem creating file");
|
||||
let mut f = BufWriter::new(f);
|
||||
f.write_all(&mut write_data_buffer).expect("error writing data");
|
||||
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)?;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user