Skip to content

Commit

Permalink
fix issue-16,issue-17
Browse files Browse the repository at this point in the history
Signed-off-by: benjamin.747 <[email protected]>
  • Loading branch information
benjamin-747 committed Dec 3, 2022
1 parent f9cd876 commit 69ebda4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
11 changes: 7 additions & 4 deletions src/crates/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ pub fn sync_rust_toolchain(opts: &ChannelOptions) -> FreightResult {
Ok(())
}



// sync the latest toolchain by given a channel name(stable, beta, nightly) or history version by version number
pub fn sync_channel(opts: &ChannelOptions, channel: &str) -> FreightResult {
let channel_name;
Expand Down Expand Up @@ -137,8 +135,13 @@ pub fn sync_channel(opts: &ChannelOptions, channel: &str) -> FreightResult {
pool.execute(move || {
let downloaded = download_file(&url, &path, Some(&hash), false);
if downloaded.is_ok() && upload {
let uploaded =
s3cmd.upload_folder(dist_path.to_str().unwrap(), &bucket_name);
let s3_path = format!(
"dist{}",
path.to_str()
.unwrap()
.replace(dist_path.to_str().unwrap(), "")
);
let uploaded = s3cmd.upload_file(&path, &s3_path, &bucket_name);
if uploaded.is_ok() && delete_after_upload {
fs::remove_file(&path).unwrap();
}
Expand Down
12 changes: 8 additions & 4 deletions src/crates/crates_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,18 @@
use std::io::Write;


use std::collections::BTreeMap;
use std::fs::{File, OpenOptions, self};
use std::fs::{self, File, OpenOptions};
use std::io::{BufRead, BufReader, ErrorKind};
use std::path::{Path, PathBuf};
use std::str;
use std::sync::{Arc, Mutex};
use threadpool::ThreadPool;

use chrono::Utc;
use log::{error, info, warn};
use serde::{Deserialize, Serialize};
use walkdir::{DirEntry, WalkDir};
use chrono::Utc;

use crate::cloud::s3::{CloudStorage, S3cmd};
use crate::config::CratesConfig;
Expand Down Expand Up @@ -258,7 +257,12 @@ pub fn download_crates_with_log(
Ok(download_succ) => {
if download_succ && opts.upload {
let s3 = S3cmd::default();
let s3_path = file.to_str().unwrap().replace(opts.crates_path.to_str().unwrap(), "");
let s3_path = format!(
"crates{}",
file.to_str()
.unwrap()
.replace(opts.crates_path.to_str().unwrap(), "")
);
info!("s3_path: {}, {}", s3_path, opts.delete_after_upload);
let uploded = s3.upload_file(&file, &s3_path, &opts.bucket_name);
if uploded.is_ok() && opts.delete_after_upload {
Expand Down

0 comments on commit 69ebda4

Please sign in to comment.