Skip to content

Conversation

@JustForFun88
Copy link

Fixes #3335

@sxyazi
Copy link
Owner

sxyazi commented Nov 18, 2025

Thank you for the patch, but this is not the right place to fix the issue - stem() is just a wrapper around Rust's file_stem(), and it should be behave the exact same way, also calling is_dir() on a &Path will involve a IO operation, but stem() should not do any IO (or even allocations). Instead, fix the issue at the upper-level copy command

@JustForFun88
Copy link
Author

Thank you for the patch, but this is not the right place to fix the issue - stem() is just a wrapper around Rust's file_stem(), and it should be behave the exact same way, also calling is_dir() on a &Path will involve a IO operation, but stem() should not do any IO (or even allocations). Instead, fix the issue at the upper-level copy command

Done

}
"name_without_ext" => {
s.extend_from_slice(&opt.separator.transform(&u.stem().unwrap_or_default()));
let name = if u.as_local().is_some_and(|p| p.is_dir()) { u.name() } else { u.stem() };
Copy link
Owner

Choose a reason for hiding this comment

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

Don't use as_local() since that only supports local files, whereas copy command should be cross-filesystem and support non-local filesystems.

Also, don't do any sync I/O on the main thread, since it can be slow, especially when the user selects many files or the files reside on a remote filesystem mount. Instead, detach those operations to an async blocking thread.

Currently the file selection state only stores the file URL, maybe we could also store a flag indicating whether the file is a directory, which would introduce new cache-invalidation problems though. Maybe the current implementation of real-time I/O isn't a big issue as long as the user doesn't do something crazy...

@sxyazi sxyazi force-pushed the main branch 2 times, most recently from 41034d0 to 449450d Compare November 24, 2025 07:23
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.

copy name_without_ext trims folder names containing dots

2 participants