diff --git a/alek_ext/fuzzystrmatch.control b/alek_ext/fuzzystrmatch.control new file mode 100644 index 0000000000..8b6e9fd993 --- /dev/null +++ b/alek_ext/fuzzystrmatch.control @@ -0,0 +1,6 @@ +# fuzzystrmatch extension +comment = 'determine similarities and distance between strings' +default_version = '1.2' +module_pathname = '$libdir/fuzzystrmatch' +relocatable = true +trusted = true diff --git a/alek_ext/pg_cron.control b/alek_ext/pg_cron.control new file mode 100644 index 0000000000..b2bdf77afc --- /dev/null +++ b/alek_ext/pg_cron.control @@ -0,0 +1,5 @@ +comment = 'Job scheduler for PostgreSQL' +default_version = '1.5' +module_pathname = '$libdir/pg_cron' +relocatable = false +schema = pg_catalog diff --git a/alek_ext/src/main.rs b/alek_ext/src/main.rs index 0bdbc7e2cf..39bb1b6487 100644 --- a/alek_ext/src/main.rs +++ b/alek_ext/src/main.rs @@ -1,5 +1,5 @@ /* - * This is a MWE of using our RemoteStorage API to call the aws stuff and download multiple files + * This is a MWE of using the RemoteStorage API to list and download files from aws */ macro_rules! alek { ($expression:expr) => { println!("{:?}", $expression); }; } @@ -17,8 +17,7 @@ use tracing_subscriber; async fn main() -> anyhow::Result<()> { let subscriber = tracing_subscriber::FmtSubscriber::new(); tracing::subscriber::set_global_default(subscriber)?; - - // TODO: right now we are using the same config parameters as pageserver; but should we have our own configs? + // TODO: read configs from a different place! let cfg_file_path = Path::new("./../.neon/pageserver.toml"); 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()))?; @@ -32,15 +31,17 @@ async fn main() -> anyhow::Result<()> { let remote_storage = GenericRemoteStorage::from_config(&remote_storage_config)?; let folder = RemotePath::new(Path::new("public_extensions"))?; + // lists all the files in the public_extensions folder let from_paths = remote_storage.list_files(Some(&folder)).await?; alek!(from_paths); for remote_from_path in from_paths { - // TODO: where should we actually save the files to? if remote_from_path.extension() == Some("control") { let file_name = remote_from_path.object_name().expect("it must exist"); - info!("{:?}",file_name); + info!("{:?}", file_name); alek!(&remote_from_path); + // download the file let mut download = remote_storage.download(&remote_from_path).await?; + // write the file to a local location 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)?); diff --git a/libs/remote_storage/src/s3_bucket.rs b/libs/remote_storage/src/s3_bucket.rs index 14786e7820..4cd39cfde4 100644 --- a/libs/remote_storage/src/s3_bucket.rs +++ b/libs/remote_storage/src/s3_bucket.rs @@ -336,7 +336,6 @@ impl RemoteStorage for S3Bucket { &self, folder: Option<&RemotePath> ) -> anyhow::Result>{ - // TODO: should we use DownloadError error type instead of anyhow::Error? let folder_name = folder.map(|x| String::from(x.object_name().expect("invalid folder name")) ); @@ -367,7 +366,6 @@ impl RemoteStorage for S3Bucket { for object in response.contents().unwrap_or_default() { let object_path = object.key().unwrap(); - println!("{:?}", object_path); let remote_path = self.s3_object_to_relative_path(object_path); all_files.push(remote_path); }