mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-17 02:12:56 +00:00
successfully unzip files and place in correct locations
This commit is contained in:
@@ -146,6 +146,7 @@ pub async fn download_extension(
|
||||
pgbin: &str,
|
||||
pg_version: &str,
|
||||
) -> Result<()> {
|
||||
info!("DOWNLOAD EXTENSION {:?}", ext_name);
|
||||
let ext_name_targz = ext_name.to_owned() + ".tar.gz";
|
||||
let ext_path = RemotePath::new(
|
||||
&Path::new(pg_version)
|
||||
@@ -171,20 +172,30 @@ pub async fn download_extension(
|
||||
info!("Download {:?} completed successfully", &ext_path);
|
||||
info!("Unzipping extension {:?}", zip_name);
|
||||
|
||||
// TODO unzip and place files in appropriate locations
|
||||
// TODO unzip and place files in appropriate locations using the library suggested by some ppl
|
||||
info!("unzip {zip_name:?}");
|
||||
std::process::Command::new("tar").arg("xvzf").arg(zip_name);
|
||||
std::process::Command::new("tar")
|
||||
.arg("xzvf")
|
||||
.arg(zip_name)
|
||||
.spawn()?
|
||||
.wait()?;
|
||||
|
||||
info!("place extension files in {local_sharedir:?}");
|
||||
info!("place library files in {local_libdir:?}");
|
||||
let zip_sharedir = format!("extensions/{ext_name}/share");
|
||||
let zip_sharedir = format!("extensions/{ext_name}/share/extension");
|
||||
info!("mv {zip_sharedir:?}/* {local_sharedir:?}");
|
||||
for file in std::fs::read_dir(zip_sharedir)? {
|
||||
let old_file = file?.path();
|
||||
let new_file =
|
||||
Path::new(&local_sharedir).join(old_file.file_name().expect("error parsing file"));
|
||||
std::fs::rename(old_file, new_file)?;
|
||||
}
|
||||
let zip_libdir = format!("extensions/{ext_name}/lib");
|
||||
std::process::Command::new("mv")
|
||||
.arg(local_sharedir)
|
||||
.arg(zip_sharedir);
|
||||
std::process::Command::new("mv")
|
||||
.arg(local_libdir)
|
||||
.arg(zip_libdir);
|
||||
info!("mv {zip_libdir:?}/* {local_libdir:?}");
|
||||
for file in std::fs::read_dir(zip_libdir)? {
|
||||
let old_file = file?.path();
|
||||
let new_file =
|
||||
Path::new(&local_libdir).join(old_file.file_name().expect("error parsing file"));
|
||||
std::fs::rename(old_file, new_file)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
BIN
embedding.tar.gz
BIN
embedding.tar.gz
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,4 +1,3 @@
|
||||
import os
|
||||
from contextlib import closing
|
||||
|
||||
import pytest
|
||||
@@ -93,12 +92,13 @@ def test_remote_extensions(
|
||||
# TODO: this will fail locally because we don't have the required dependencies
|
||||
cur.execute("CREATE EXTENSION anon")
|
||||
cur.execute("SELECT extname FROM pg_extension")
|
||||
assert "embedding" in [x[0] for x in cur.fetchall()]
|
||||
assert "anon" in [x[0] for x in cur.fetchall()]
|
||||
|
||||
# TODO: should we try libraries too?
|
||||
# TODO: try to load libraries as well
|
||||
|
||||
finally:
|
||||
cleanup_files = ["embedding.tar.gz", "anon.tar.gz"]
|
||||
_cleanup_folders = ["extensions"]
|
||||
# for file in cleanup_files:
|
||||
# os.remove(file)
|
||||
log.info("For now, please manually cleanup ", cleanup_files)
|
||||
log.info(f"For now, please manually cleanup {cleanup_files}")
|
||||
|
||||
Reference in New Issue
Block a user