Skip to content

Conversation

@sxyazi
Copy link
Owner

@sxyazi sxyazi commented Dec 6, 2025

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors directory traversal logic by extracting it into a reusable generic function and splits the combined FilePaste operation into separate FileCopy and FileCut operations for better code clarity and maintainability.

Key Changes:

  • Introduced a new traverse.rs module with a generic traverse function that abstracts directory traversal logic
  • Split FilePaste into distinct FileCopy and FileCut operations with their own progress tracking, input/output types, and implementations
  • Updated field names in FileInDelete (from length to cha) and FileInUpload (added cha and cache fields) to align with the new traversal pattern

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
yazi-vfs/src/provider/sftp/sftp.rs Enhanced error handling for SFTP rename operation to gracefully handle NotFound errors
yazi-scheduler/src/scheduler.rs Updated imports and method calls to use FileCopy/FileCut instead of FilePaste; updated FileInDelete and FileInUpload parameter initialization
yazi-scheduler/src/progress.rs Split FilePaste progress tracking into separate FileCopy and FileCut variants
yazi-scheduler/src/out.rs Split FileOutPaste into FileOutCopy/FileOutCopyDo and FileOutCut/FileOutCutDo
yazi-scheduler/src/in.rs Split FileInPaste into FileInCopy and FileInCut; renamed FileInUploadDo to FileInUpload
yazi-scheduler/src/file/traverse.rs New module implementing generic directory traversal with Traverse trait and traverse function
yazi-scheduler/src/file/progress.rs Split FileProgPaste into FileProgCopy and FileProgCut with separate implementations
yazi-scheduler/src/file/out.rs Implemented separate output types for copy and cut operations
yazi-scheduler/src/file/mod.rs Added traverse module to exports
yazi-scheduler/src/file/in.rs Refactored input types to separate copy and cut operations; updated FileInUpload structure
yazi-scheduler/src/file/file.rs Refactored paste/paste_do into copy/copy_do and cut/cut_do using the new traverse function; updated delete, hardlink, download, and upload methods to use traverse
yazi-plugin/preset/components/tasks.lua Updated task icon and progress rendering to distinguish between FileCopy and FileCut

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

task,
async |_dir| Ok(()),
async |task, cha| {
let cache = task.cache.as_ref().context("Cannot determine cache path")?;
Copy link

Copilot AI Dec 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The task.cache field will be None for single file uploads (non-directory cases), causing this line to return an error. When traverse is called with a file (not directory), it immediately calls on_file at line 143 of traverse.rs with the original task, which has cache: None (as initialized in scheduler.rs line 246). The cache is only populated by the spawn method during directory traversal.

Consider initializing the cache before calling traverse, or compute it on-demand similar to how download_do handles it at line 286.

Suggested change
let cache = task.cache.as_ref().context("Cannot determine cache path")?;
let cache = match task.cache.as_ref() {
Some(cache) => cache,
None => task.url.cache().context("Cannot determine cache path")?,
};

Copilot uses AI. Check for mistakes.
@sxyazi sxyazi merged commit d2e9e72 into main Dec 6, 2025
10 checks passed
@sxyazi sxyazi deleted the pr-15dff049 branch December 6, 2025 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants