Skip to content

Commit

Permalink
Replaced shlex quoting in async code
Browse files Browse the repository at this point in the history
myOmikron committed Jul 22, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 30ee84c commit 1060165
Showing 6 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/asynchronous/compact.rs
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ pub async fn compact(
) -> Result<(), CompactError> {
let local_path = common_options.local_path.as_ref().map_or("borg", |x| x);

let args = compact_fmt_args(options, common_options).map_err(|_| CompactError::ShlexError)?;
let args = compact_fmt_args(options, common_options);
debug!("Calling borg: {local_path} {args}");
let args = shlex::split(&args).ok_or(CompactError::ShlexError)?;
let res = tokio::process::Command::new(local_path)
6 changes: 2 additions & 4 deletions src/asynchronous/create.rs
Original file line number Diff line number Diff line change
@@ -25,8 +25,7 @@ pub async fn create(
) -> Result<Create, CreateError> {
let local_path = common_options.local_path.as_ref().map_or("borg", |x| x);

let args =
create_fmt_args(options, common_options, false).map_err(|_| CreateError::ShlexError)?;
let args = create_fmt_args(options, common_options, false);
debug!("Calling borg: {local_path} {args}");
let args = shlex::split(&args).ok_or(CreateError::ShlexError)?;
let res = execute_borg(local_path, args, &options.passphrase).await?;
@@ -97,8 +96,7 @@ pub async fn create_progress(
) -> Result<Create, CreateError> {
let local_path = common_options.local_path.as_ref().map_or("borg", |x| x);

let args =
create_fmt_args(options, common_options, true).map_err(|_| CreateError::ShlexError)?;
let args = create_fmt_args(options, common_options, true);
debug!("Calling borg: {local_path} {args}");
let args = shlex::split(&args).ok_or(CreateError::ShlexError)?;
let mut child = if let Some(passphrase) = &options.passphrase {
2 changes: 1 addition & 1 deletion src/asynchronous/init.rs
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ use crate::errors::InitError;
pub async fn init(options: &InitOptions, common_options: &CommonOptions) -> Result<(), InitError> {
let local_path = common_options.local_path.as_ref().map_or("borg", |x| x);

let args = init_fmt_args(options, common_options).map_err(|_| InitError::ShlexError)?;
let args = init_fmt_args(options, common_options);
let passphrase = options.encryption_mode.get_passphrase();

debug!("Calling borg: {local_path} {args}");
2 changes: 1 addition & 1 deletion src/asynchronous/list.rs
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ pub async fn list(
) -> Result<ListRepository, ListError> {
let local_path = common_options.local_path.as_ref().map_or("borg", |x| x);

let args = list_fmt_args(options, common_options).map_err(|_| ListError::ShlexError)?;
let args = list_fmt_args(options, common_options);
debug!("Calling borg: {local_path} {args}");
let args = shlex::split(&args).ok_or(ListError::ShlexError)?;
let res = execute_borg(local_path, args, &options.passphrase).await?;
2 changes: 1 addition & 1 deletion src/asynchronous/mount.rs
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ pub async fn mount(
) -> Result<(), MountError> {
let local_path = common_options.local_path.as_ref().map_or("borg", |x| x);

let args = mount_fmt_args(options, common_options).map_err(|_| MountError::ShlexError)?;
let args = mount_fmt_args(options, common_options);
debug!("Calling borg: {local_path} {args}");
let args = shlex::split(&args).ok_or(MountError::ShlexError)?;
let res = execute_borg(local_path, args, &options.passphrase).await?;
2 changes: 1 addition & 1 deletion src/asynchronous/prune.rs
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ pub async fn prune(
) -> Result<(), PruneError> {
let local_path = common_options.local_path.as_ref().map_or("borg", |x| x);

let args = prune_fmt_args(options, common_options).map_err(|_| PruneError::ShlexError)?;
let args = prune_fmt_args(options, common_options);
debug!("Calling borg: {local_path} {args}");
let args = shlex::split(&args).ok_or(PruneError::ShlexError)?;
let res = execute_borg(local_path, args, &options.passphrase).await?;

0 comments on commit 1060165

Please sign in to comment.