Skip to content

Commit feeff39

Browse files
Merge branch 'main' into update-dependencies
2 parents 92be192 + 9df95c6 commit feeff39

File tree

11 files changed

+37
-13
lines changed

11 files changed

+37
-13
lines changed

postgresql_archive/src/archive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub async fn extract(url: &str, bytes: &Vec<u8>, out_dir: &Path) -> Result<Vec<P
4545
let extractor_fn = extractor::registry::get(url)?;
4646
let mut extract_directories = extractor::ExtractDirectories::default();
4747
extract_directories.add_mapping(Regex::new(".*")?, out_dir.to_path_buf());
48-
extractor_fn(bytes, extract_directories)
48+
extractor_fn(bytes, &extract_directories)
4949
}
5050

5151
#[cfg(test)]

postgresql_archive/src/configuration/theseus/extractor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use tracing::{debug, instrument, warn};
1313
/// # Errors
1414
/// Returns an error if the extraction fails.
1515
#[instrument(skip(bytes))]
16-
pub fn extract(bytes: &Vec<u8>, extract_directories: ExtractDirectories) -> Result<Vec<PathBuf>> {
16+
pub fn extract(bytes: &Vec<u8>, extract_directories: &ExtractDirectories) -> Result<Vec<PathBuf>> {
1717
let out_dir = extract_directories.get_path(".")?;
1818

1919
let parent_dir = if let Some(parent) = out_dir.parent() {
@@ -41,7 +41,7 @@ pub fn extract(bytes: &Vec<u8>, extract_directories: ExtractDirectories) -> Resu
4141
debug!("Extracting archive to {}", extract_dir.to_string_lossy());
4242
let mut archive_extract_directories = ExtractDirectories::default();
4343
archive_extract_directories.add_mapping(Regex::new(".*")?, extract_dir.clone());
44-
let files = tar_gz_extract(bytes, archive_extract_directories)?;
44+
let files = tar_gz_extract(bytes, &archive_extract_directories)?;
4545

4646
if out_dir.exists() {
4747
debug!(

postgresql_archive/src/configuration/zonky/extractor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use zip::ZipArchive;
1616
/// Returns an error if the extraction fails.
1717
#[expect(clippy::case_sensitive_file_extension_comparisons)]
1818
#[instrument(skip(bytes))]
19-
pub fn extract(bytes: &Vec<u8>, extract_directories: ExtractDirectories) -> Result<Vec<PathBuf>> {
19+
pub fn extract(bytes: &Vec<u8>, extract_directories: &ExtractDirectories) -> Result<Vec<PathBuf>> {
2020
let out_dir = extract_directories.get_path(".")?;
2121
let parent_dir = if let Some(parent) = out_dir.parent() {
2222
parent
@@ -63,7 +63,7 @@ pub fn extract(bytes: &Vec<u8>, extract_directories: ExtractDirectories) -> Resu
6363

6464
let mut archive_extract_directories = ExtractDirectories::default();
6565
archive_extract_directories.add_mapping(Regex::new(".*")?, extract_dir.clone());
66-
let files = tar_xz_extract(&archive_bytes, archive_extract_directories)?;
66+
let files = tar_xz_extract(&archive_bytes, &archive_extract_directories)?;
6767

6868
if out_dir.exists() {
6969
debug!(

postgresql_archive/src/extractor/registry.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ static REGISTRY: LazyLock<Arc<Mutex<RepositoryRegistry>>> =
1212
LazyLock::new(|| Arc::new(Mutex::new(RepositoryRegistry::default())));
1313

1414
type SupportsFn = fn(&str) -> Result<bool>;
15-
type ExtractFn = fn(&Vec<u8>, ExtractDirectories) -> Result<Vec<PathBuf>>;
15+
type ExtractFn = fn(&Vec<u8>, &ExtractDirectories) -> Result<Vec<PathBuf>>;
1616

1717
/// Singleton struct to store extractors
1818
#[expect(clippy::type_complexity)]
@@ -107,7 +107,7 @@ mod tests {
107107
let extractor = get(url)?;
108108
let mut extract_directories = ExtractDirectories::default();
109109
extract_directories.add_mapping(Regex::new(".*")?, PathBuf::from("test"));
110-
assert!(extractor(&Vec::new(), extract_directories).is_ok());
110+
assert!(extractor(&Vec::new(), &extract_directories).is_ok());
111111
Ok(())
112112
}
113113

postgresql_archive/src/extractor/tar_gz_extractor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use tracing::{debug, instrument, warn};
1414
/// # Errors
1515
/// Returns an error if the extraction fails.
1616
#[instrument(skip(bytes))]
17-
pub fn extract(bytes: &Vec<u8>, extract_directories: ExtractDirectories) -> Result<Vec<PathBuf>> {
17+
pub fn extract(bytes: &Vec<u8>, extract_directories: &ExtractDirectories) -> Result<Vec<PathBuf>> {
1818
let mut files = Vec::new();
1919
let input = BufReader::new(Cursor::new(bytes));
2020
let decoder = GzDecoder::new(input);

postgresql_archive/src/extractor/tar_xz_extractor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use tracing::{debug, instrument, warn};
1414
/// # Errors
1515
/// Returns an error if the extraction fails.
1616
#[instrument(skip(bytes))]
17-
pub fn extract(bytes: &Vec<u8>, extract_directories: ExtractDirectories) -> Result<Vec<PathBuf>> {
17+
pub fn extract(bytes: &Vec<u8>, extract_directories: &ExtractDirectories) -> Result<Vec<PathBuf>> {
1818
let mut files = Vec::new();
1919
let input = BufReader::new(Cursor::new(bytes));
2020
let decoder = XzDecoder::new(input);

postgresql_archive/src/extractor/zip_extractor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use zip::ZipArchive;
1313
/// # Errors
1414
/// Returns an error if the extraction fails.
1515
#[instrument(skip(bytes))]
16-
pub fn extract(bytes: &Vec<u8>, extract_directories: ExtractDirectories) -> Result<Vec<PathBuf>> {
16+
pub fn extract(bytes: &Vec<u8>, extract_directories: &ExtractDirectories) -> Result<Vec<PathBuf>> {
1717
let mut files = Vec::new();
1818
let reader = Cursor::new(bytes);
1919
let mut archive = ZipArchive::new(reader).map_err(|_| io::Error::other("Zip error"))?;

postgresql_embedded/src/postgresql.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ impl PostgreSQL {
145145
/// Set up the database by extracting the archive and initializing the database.
146146
/// If the installation directory already exists, the archive will not be extracted.
147147
/// If the data directory already exists, the database will not be initialized.
148+
///
149+
/// # Errors
150+
///
151+
/// If the installation fails, an error will be returned.
148152
#[instrument(skip(self))]
149153
pub async fn setup(&mut self) -> Result<()> {
150154
match self.installed_dir() {
@@ -259,6 +263,10 @@ impl PostgreSQL {
259263

260264
/// Start the database and wait for the startup to complete.
261265
/// If the port is set to `0`, the database will be started on a random port.
266+
///
267+
/// # Errors
268+
///
269+
/// If the database fails to start, an error will be returned.
262270
#[instrument(skip(self))]
263271
pub async fn start(&mut self) -> Result<()> {
264272
if self.settings.port == 0 {
@@ -299,6 +307,10 @@ impl PostgreSQL {
299307
}
300308

301309
/// Stop the database gracefully (smart mode) and wait for the shutdown to complete.
310+
///
311+
/// # Errors
312+
///
313+
/// If the database fails to stop, an error will be returned.
302314
#[instrument(skip(self))]
303315
pub async fn stop(&self) -> Result<()> {
304316
debug!(
@@ -333,6 +345,10 @@ impl PostgreSQL {
333345
}
334346

335347
/// Create a new database with the given name.
348+
///
349+
/// # Errors
350+
///
351+
/// If the database creation fails, an error will be returned.
336352
#[instrument(skip(self))]
337353
pub async fn create_database<S>(&self, database_name: S) -> Result<()>
338354
where
@@ -359,6 +375,10 @@ impl PostgreSQL {
359375
}
360376

361377
/// Check if a database with the given name exists.
378+
///
379+
/// # Errors
380+
///
381+
/// If the query fails, an error will be returned.
362382
#[instrument(skip(self))]
363383
pub async fn database_exists<S>(&self, database_name: S) -> Result<bool>
364384
where
@@ -383,6 +403,10 @@ impl PostgreSQL {
383403
}
384404

385405
/// Drop a database with the given name.
406+
///
407+
/// # Errors
408+
///
409+
/// If the database does not exist or if the drop command fails, an error will be returned.
386410
#[instrument(skip(self))]
387411
pub async fn drop_database<S>(&self, database_name: S) -> Result<()>
388412
where

postgresql_extensions/src/repository/portal_corp/repository.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl Repository for PortalCorp {
8080
extract_directories.add_mapping(Regex::new(r"\.(dll|dylib|so)$")?, library_dir);
8181
extract_directories.add_mapping(Regex::new(r"\.(control|sql)$")?, extension_dir);
8282
let bytes = &archive.to_vec();
83-
let files = zip_extract(bytes, extract_directories)?;
83+
let files = zip_extract(bytes, &extract_directories)?;
8484
Ok(files)
8585
}
8686
}

postgresql_extensions/src/repository/steampipe/repository.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl Repository for Steampipe {
9393
extract_directories.add_mapping(Regex::new(r"\.(dll|dylib|so)$")?, library_dir);
9494
extract_directories.add_mapping(Regex::new(r"\.(control|sql)$")?, extension_dir);
9595
let bytes = &archive.to_vec();
96-
let files = tar_gz_extract(bytes, extract_directories)?;
96+
let files = tar_gz_extract(bytes, &extract_directories)?;
9797
Ok(files)
9898
}
9999
}

0 commit comments

Comments
 (0)