Skip to content

Commit

Permalink
feat(cli): download path is familiar to users
Browse files Browse the repository at this point in the history
  • Loading branch information
iancoleman committed Dec 13, 2023
1 parent b90f958 commit 4f780f7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/memcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ jobs:
- name: Start a client to download files
run: |
cargo run --bin safe --release -- --log-output-dest=data-dir files download
ls -l $CLIENT_DATA_PATH/downloaded_files
downloaded_files=$(ls $CLIENT_DATA_PATH/downloaded_files | wc -l)
ls -l ~/Downloads
downloaded_files=$(ls ~/Downloads | wc -l)
if [ $downloaded_files -lt 1 ]; then
echo "Only downloaded $downloaded_files files, less than the 1 file uploaded"
exit 1
Expand All @@ -195,14 +195,14 @@ jobs:
- name: Start a client to download the same files again
run: |
cargo run --bin safe --release -- --log-output-dest=data-dir files download --show-holders
ls -l $CLIENT_DATA_PATH/downloaded_files
downloaded_files=$(ls $CLIENT_DATA_PATH/downloaded_files | wc -l)
ls -l ~/Downloads
downloaded_files=$(ls ~/Downloads | wc -l)
if [ $downloaded_files -lt 1 ]; then
echo "Only downloaded $downloaded_files files, less than the 1 file uploaded"
exit 1
fi
file_size1=$(stat -c "%s" ./the-test-data.zip)
file_size2=$(stat -c "%s" $CLIENT_DATA_PATH/downloaded_files/the-test-data.zip)
file_size2=$(stat -c "%s" ~/Downloads/the-test-data.zip)
if [ $file_size1 != $file_size2 ]; then
echo "The downloaded file has a different size $file_size2 to the original $file_size1."
exit 1
Expand Down
7 changes: 4 additions & 3 deletions sn_cli/src/subcommands/files/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ pub(crate) async fn files_cmds(
);
}

let file_api: Files = Files::new(client.clone(), root_dir.to_path_buf());
let download_dir = dirs_next::download_dir().unwrap_or(root_dir.to_path_buf());
let file_api: Files = Files::new(client.clone(), download_dir.clone());

match (file_name, file_addr) {
(Some(name), Some(address)) => {
Expand All @@ -127,7 +128,7 @@ pub(crate) async fn files_cmds(
&file_api,
&xor_name,
&name,
root_dir,
&download_dir,
show_holders,
batch_size,
)
Expand Down Expand Up @@ -436,7 +437,7 @@ async fn download_files(
) -> Result<()> {
info!("Downloading with batch size of {}", batch_size);
let uploaded_files_path = root_dir.join("uploaded_files");
let download_path = root_dir.join("downloaded_files");
let download_path = dirs_next::download_dir().unwrap_or(root_dir.join("downloaded_files"));
std::fs::create_dir_all(download_path.as_path())?;

let file = std::fs::File::open(&uploaded_files_path)?;
Expand Down

0 comments on commit 4f780f7

Please sign in to comment.