diff --git a/CHANGELOG.md b/CHANGELOG.md index d17c8697..4e66c785 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,7 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/): - New `relay-notify-push` DDS event to customize the notification handler ([#3642]) - New `ind-app-title` DDS event to customize the app title ([#3684]) - New `fs.unique()` creates a unique file or directory ([#3677]) -- New `download` DDS event fires when remote files are downloaded +- New `download` DDS event fires when remote files are downloaded ([#3687]) - New `cx.which` API to access the which component state ([#3617]) - New `ind-which-activate` DDS event to change the which component behavior ([#3608]) @@ -1661,3 +1661,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/): [#3677]: https://github.com/sxyazi/yazi/pull/3677 [#3678]: https://github.com/sxyazi/yazi/pull/3678 [#3684]: https://github.com/sxyazi/yazi/pull/3684 +[#3687]: https://github.com/sxyazi/yazi/pull/3687 diff --git a/yazi-scheduler/src/file/file.rs b/yazi-scheduler/src/file/file.rs index 3cfc0b3c..6a529ec7 100644 --- a/yazi-scheduler/src/file/file.rs +++ b/yazi-scheduler/src/file/file.rs @@ -403,7 +403,7 @@ impl File { pub(crate) async fn upload_do(&self, task: FileInUpload) -> Result<(), FileOutUploadDo> { let cha = task.cha.unwrap(); let cache = ctx!(task, task.cache.as_ref(), "Cannot determine cache path")?; - let lock = ctx!(task, task.url.cache_lock(), "Cannot determine cache lock")?; + let lock = ctx!(task, task.target.cache_lock(), "Cannot determine cache lock")?; let hash = ctx!(task, Local::regular(&lock).read_to_string().await, "Cannot read cache lock")?; let hash = ctx!(task, u128::from_str_radix(&hash, 16), "Cannot parse hash from lock")?; @@ -412,7 +412,7 @@ impl File { } let tmp = - ctx!(task, Transaction::tmp(&task.url).await, "Cannot determine temporary upload path")?; + ctx!(task, Transaction::tmp(&task.target).await, "Cannot determine temporary upload path")?; let mut it = ctx!( task, provider::copy_with_progress(cache, &tmp, Attrs { @@ -428,15 +428,15 @@ impl File { match progress_or_break!(it, task.done) { Ok(0) => { let cha = - ctx!(task, Self::cha(&task.url, true, None).await, "Cannot stat original file")?; + ctx!(task, Self::cha(&task.target, true, None).await, "Cannot stat original file")?; if hash != cha.hash_u128() { Err(anyhow!("Failed to work on: {task:?}: remote file has changed during upload"))?; } - ctx!(task, provider::rename(&tmp, &task.url).await, "Cannot persist uploaded file")?; + ctx!(task, provider::rename(&tmp, &task.target).await, "Cannot persist uploaded file")?; let cha = - ctx!(task, Self::cha(&task.url, true, None).await, "Cannot stat uploaded file")?; + ctx!(task, Self::cha(&task.target, true, None).await, "Cannot stat uploaded file")?; let hash = format!("{:x}", cha.hash_u128()); ctx!(task, Local::regular(&lock).write(hash).await, "Cannot lock cache")?; diff --git a/yazi-scheduler/src/file/in.rs b/yazi-scheduler/src/file/in.rs index 3428f591..898616da 100644 --- a/yazi-scheduler/src/file/in.rs +++ b/yazi-scheduler/src/file/in.rs @@ -197,9 +197,9 @@ pub(crate) struct FileInDownload { // --- Upload #[derive(Clone, Debug)] pub(crate) struct FileInUpload { - pub(crate) id: Id, - pub(crate) url: UrlBuf, - pub(crate) cha: Option, - pub(crate) cache: Option, - pub(crate) done: CompletionToken, + pub(crate) id: Id, + pub(crate) target: UrlBuf, + pub(crate) cha: Option, + pub(crate) cache: Option, + pub(crate) done: CompletionToken, } diff --git a/yazi-scheduler/src/file/traverse.rs b/yazi-scheduler/src/file/traverse.rs index 45fcf3ff..37f5beee 100644 --- a/yazi-scheduler/src/file/traverse.rs +++ b/yazi-scheduler/src/file/traverse.rs @@ -132,25 +132,25 @@ impl Traverse for FileInUpload { fn follow(&self) -> bool { true } - fn from(&self) -> Url<'_> { self.url.as_url() } + fn from(&self) -> Url<'_> { self.target.as_url() } async fn init(&mut self) -> anyhow::Result { if self.cha.is_none() { self.cha = Some(super::File::cha(self.from(), self.follow(), None).await?) } if self.cache.is_none() { - self.cache = self.url.cache(); + self.cache = self.target.cache(); } Ok(self.cha.unwrap()) } fn spawn(&self, from: UrlBuf, _to: Option, cha: Cha) -> Self { Self { - id: self.id, - cha: Some(cha), - cache: from.cache(), - url: from, - done: self.done.clone(), + id: self.id, + cha: Some(cha), + cache: from.cache(), + target: from, + done: self.done.clone(), } } diff --git a/yazi-scheduler/src/scheduler.rs b/yazi-scheduler/src/scheduler.rs index 495b5ba3..83a1aa38 100644 --- a/yazi-scheduler/src/scheduler.rs +++ b/yazi-scheduler/src/scheduler.rs @@ -164,19 +164,19 @@ impl Scheduler { task.done.clone() } - pub fn file_upload(&self, url: UrlBuf) { + pub fn file_upload(&self, target: UrlBuf) { let mut ongoing = self.ongoing.lock(); - let task = ongoing.add::(format!("Upload {}", url.display())); + let task = ongoing.add::(format!("Upload {}", target.display())); - if !url.kind().is_remote() { + if !target.kind().is_remote() { return self .ops .out(task.id, FileOutUpload::Fail("Cannot upload non-remote file".to_owned())); }; - task.set_hook(HookInUpload { id: task.id, target: url.clone() }); + task.set_hook(HookInUpload { id: task.id, target: target.clone() }); self.file.submit( - FileInUpload { id: task.id, url, cha: None, cache: None, done: task.done.clone() }, + FileInUpload { id: task.id, target, cha: None, cache: None, done: task.done.clone() }, LOW, ); }