Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use_nix
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tmp-postgrust"
version = "0.9.0"
version = "0.10.0"
authors = ["John Children <[email protected]>"]
license = "MIT"
edition = "2018"
Expand Down
18 changes: 18 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{ pkgs ? import <nixpkgs> {} }:

pkgs.mkShell {
name = "diesel-tracing-dev-env";
buildInputs = with pkgs; [
cargo
rustc
rustfmt
clippy

pkg-config
postgresql
libmysqlclient
sqlite
];

LD_LIBRARY_PATH = "${pkgs.postgresql.lib}/lib";
}
22 changes: 11 additions & 11 deletions src/asynchronous.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use tempfile::TempDir;
use tokio::fs::create_dir_all;
use tokio::io::Lines;
use tokio::process::{ChildStderr, ChildStdout};
use tokio::sync::{Semaphore, SemaphorePermit};
use tokio::{
io::BufReader,
process::{Child, Command},
Expand All @@ -20,9 +19,6 @@ use crate::errors::{ProcessCapture, TmpPostgrustError, TmpPostgrustResult};
use crate::search::{all_dir_entries, build_copy_dst_path, find_postgresql_command};
use crate::POSTGRES_UID_GID;

/// Limit the total processes that can be running at any one time.
pub(crate) static MAX_CONCURRENT_PROCESSES: Semaphore = Semaphore::const_new(8);

#[instrument(skip(command, fail))]
async fn exec_process(
command: &mut Command,
Expand Down Expand Up @@ -94,12 +90,18 @@ pub(crate) async fn exec_copy_dir(src_dir: &Path, dst_dir: &Path) -> TmpPostgrus
.await
.map_err(TmpPostgrustError::CopyCachedInitDBFailedFileNotFound)?;
}
let src_dir = src_dir.to_owned();
let dst_dir = dst_dir.to_owned();

for entry in others {
reflink_copy::reflink_or_copy(&entry, build_copy_dst_path(&entry, src_dir, dst_dir)?)
.map_err(TmpPostgrustError::CopyCachedInitDBFailedFileNotFound)?;
}

tokio::task::spawn_blocking(move || {
for entry in others {
reflink_copy::reflink_or_copy(&entry, build_copy_dst_path(&entry, &src_dir, &dst_dir)?)
.map_err(TmpPostgrustError::CopyCachedInitDBFailedFileNotFound)?;
}
Ok(())
})
.await
.unwrap()?;
Ok(())
}

Expand Down Expand Up @@ -193,8 +195,6 @@ pub struct ProcessGuard {
/// Socket directory for connection to the running process.
pub(crate) socket_dir: Arc<TempDir>,
pub(crate) postgres_process: Child,
// Limit the total concurrent processes.
pub(crate) _process_permit: SemaphorePermit<'static>,
}

impl Drop for ProcessGuard {
Expand Down
Loading
Loading