aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe')
-rw-r--r--crates/shirabe/src/downloader/path_downloader.rs104
-rw-r--r--crates/shirabe/src/util/auth_helper.rs2
-rw-r--r--crates/shirabe/tests/util/auth_helper_test.rs2
3 files changed, 52 insertions, 56 deletions
diff --git a/crates/shirabe/src/downloader/path_downloader.rs b/crates/shirabe/src/downloader/path_downloader.rs
index 2f385e8e..076f313d 100644
--- a/crates/shirabe/src/downloader/path_downloader.rs
+++ b/crates/shirabe/src/downloader/path_downloader.rs
@@ -348,61 +348,57 @@ impl DownloaderInterface for PathDownloader {
let mut is_fallback = false;
if Self::STRATEGY_SYMLINK == current_strategy {
- let symlink_result: anyhow::Result<anyhow::Result<()>> =
- (|| {
- if Platform::is_windows() {
- // Implement symlinks as NTFS junctions on Windows
- if output {
- self.inner.io.borrow().write_error3(
- &format!("Junctioning from {}", url),
- false,
- io_interface::NORMAL,
- );
- }
- Ok(self
- .inner
- .filesystem
- .borrow_mut()
- .junction(&real_url, &path))
+ let symlink_result: anyhow::Result<anyhow::Result<()>> = (|| {
+ if Platform::is_windows() {
+ // Implement symlinks as NTFS junctions on Windows
+ if output {
+ self.inner.io.borrow().write_error3(
+ &format!("Junctioning from {}", url),
+ false,
+ io_interface::NORMAL,
+ );
+ }
+ Ok(self
+ .inner
+ .filesystem
+ .borrow_mut()
+ .junction(&real_url, &path))
+ } else {
+ let path = path.trim_end_matches('/').to_string();
+ if output {
+ self.inner.io.borrow().write_error3(
+ &format!("Symlinking from {}", url),
+ false,
+ io_interface::NORMAL,
+ );
+ }
+ if transport_options
+ .get("relative")
+ .and_then(|v| v.as_bool())
+ .unwrap_or(false)
+ {
+ let absolute_path =
+ if !self.inner.filesystem.borrow_mut().is_absolute_path(&path) {
+ std::path::Path::new(&Platform::get_cwd(false)?)
+ .join(&path)
+ .into_os_string()
+ .into_string()
+ .unwrap()
+ } else {
+ path.clone()
+ };
+ let shortest_path = self.inner.filesystem.borrow_mut().find_shortest_path(
+ &absolute_path,
+ &real_url,
+ false,
+ true,
+ );
+ Ok(symfony_filesystem.symlink(&format!("{}/", shortest_path), &path))
} else {
- let path = path.trim_end_matches('/').to_string();
- if output {
- self.inner.io.borrow().write_error3(
- &format!("Symlinking from {}", url),
- false,
- io_interface::NORMAL,
- );
- }
- if transport_options
- .get("relative")
- .and_then(|v| v.as_bool())
- .unwrap_or(false)
- {
- let absolute_path =
- if !self.inner.filesystem.borrow_mut().is_absolute_path(&path) {
- std::path::Path::new(&Platform::get_cwd(false)?)
- .join(&path)
- .into_os_string()
- .into_string()
- .unwrap()
- } else {
- path.clone()
- };
- let shortest_path = self
- .inner
- .filesystem
- .borrow_mut()
- .find_shortest_path(&absolute_path, &real_url, false, true);
- Ok(symfony_filesystem.symlink(
- &format!("{}/", shortest_path),
- &path,
- false,
- ))
- } else {
- Ok(symfony_filesystem.symlink(&format!("{}/", real_url), &path, false))
- }
+ Ok(symfony_filesystem.symlink(&format!("{}/", real_url), &path))
}
- })();
+ }
+ })();
match symlink_result? {
Ok(()) => {}
@@ -453,7 +449,7 @@ impl DownloaderInterface for PathDownloader {
// argument, but the external-package Filesystem stub does not model the iterator type
// that ArchivableFilesFinder (an IteratorAggregate) would be wrapped into, so None is
// passed and the mirrored file list is not restricted.
- symfony_filesystem.mirror(&real_url, &path, None, &IndexMap::new())?;
+ symfony_filesystem.mirror(&real_url, &path)?;
}
if output {
diff --git a/crates/shirabe/src/util/auth_helper.rs b/crates/shirabe/src/util/auth_helper.rs
index ab8769e8..ac7caa35 100644
--- a/crates/shirabe/src/util/auth_helper.rs
+++ b/crates/shirabe/src/util/auth_helper.rs
@@ -593,7 +593,7 @@ impl AuthHelper {
);
authentication_display_message = Some("Using SSL client certificate".to_string());
} else {
- let auth_str = base64_encode(&format!("{}:{}", username, password));
+ let auth_str = base64_encode(format!("{}:{}", username, password));
headers.push(PhpMixed::String(format!(
"Authorization: Basic {}",
auth_str,
diff --git a/crates/shirabe/tests/util/auth_helper_test.rs b/crates/shirabe/tests/util/auth_helper_test.rs
index 6b376f97..2f2feb23 100644
--- a/crates/shirabe/tests/util/auth_helper_test.rs
+++ b/crates/shirabe/tests/util/auth_helper_test.rs
@@ -340,7 +340,7 @@ fn add_authentication_header_with_basic_http_authentication(
let expected = format!(
"Authorization: Basic {}",
- base64_encode(&format!("{}:{}", username, password))
+ base64_encode(format!("{}:{}", username, password))
);
let options = f