Skip to content

Commit ec8cb65

Browse files
committed
🐛 hotfix(download): Create user specified directory if inexistent
1 parent 0471f6e commit ec8cb65

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl Client {
3737
let peers = Arc::new(Mutex::new(HashMap::new()));
3838
let http_client = reqwest::Client::new();
3939
let sessions = Arc::new(Mutex::new(HashMap::new()));
40-
let download_dir = "/home/wyli/Downloads".to_string();
40+
let download_dir = "/home/localsend".to_string();
4141

4242
Ok(Self {
4343
device,

src/server/http.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ impl Client {
3535
.layer(RequestBodyLimitLayer::new(1024 * 1024 * 1024))
3636
.layer(Extension(self.device.clone()))
3737
.layer(Extension(self.sessions.clone()))
38+
.layer(Extension(self.download_dir.clone()))
3839
.with_state(peers)
3940

4041
}

src/transfer/upload.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,13 @@ pub async fn register_prepare_upload(
192192
pub async fn register_upload(
193193
Query(params): Query<UploadParams>,
194194
Extension(sessions): Extension<Arc<Mutex<HashMap<String, Session>>>>,
195+
Extension(download_dir): Extension<String>,
195196
body: Bytes,
196197
) -> impl IntoResponse {
197198
// Extract query parameters
198199
let session_id = &params.session_id;
199200
let file_id = &params.file_id;
200201
let token = &params.token;
201-
let download_dir = PathBuf::from("/home/wyli/Downloads");
202202

203203
// Get session and validate
204204
let mut sessions_lock = sessions.lock().await;
@@ -237,7 +237,7 @@ pub async fn register_upload(
237237
}
238238

239239
// Create file path
240-
let file_path = download_dir.join(&file_metadata.file_name);
240+
let file_path = format!("{}/{}", download_dir, file_metadata.file_name);
241241

242242
// Write file
243243
if let Err(e) = tokio::fs::write(&file_path, body).await {

0 commit comments

Comments
 (0)