Repository navigation
Conversation
…with native `std::fs` for improved reliability.
… unnecessary line breaks.
…reaks for improved readability.
|
Great work @wirwolf |
| if src.is_dir() { std::fs::remove_dir_all(src) } else { std::fs::remove_file(src) } | ||
| } | ||
|
|
||
| fn copy_item_preserving_attrs(src: &Path, dst: &Path) -> std::io::Result<()> { |
There was a problem hiding this comment.
copy/move functions should be moved to czkawka_core, because this is thing duplicated between all gui backends(and in future maybe even CLI will add this)
| } else { | ||
| std::fs::copy(src, dst)?; | ||
| let times = std::fs::FileTimes::new().set_accessed(metadata.accessed()?).set_modified(metadata.modified()?); | ||
| std::fs::OpenOptions::new().write(true).open(dst)?.set_times(times)?; |
There was a problem hiding this comment.
This probably for readonly files will throw an error - don't know this for sure, so test, testing this potential problem should be added to PR
| } | ||
|
|
||
| fn move_item_preserving_attrs(src: &Path, dst: &Path) -> std::io::Result<()> { | ||
| if std::fs::rename(src, dst).is_ok() { |
There was a problem hiding this comment.
Not for all rename errors, we should use copy fallback.
I think, that only in case of ErrorKind::CrossesDevices, this should try to move file/folder with alternative method
|
Hi @wirwolf, are you still planning to work on this ? |
Hey. Maybe a little bit later. I build your project locally, run it on my NAS and find all issues in my data. If you ask about comments for code formatting - i add finishing this MR to my to-do list PS: Also, if it's interesting, I run this project in a Docker container to run on a remote server and control the application on a browser. Its very comfortable |
Problem
When files are moved from Czkawka/Krokiet using the move action, moved files receive the current modification time instead of keeping their original metadata. This is especially problematic for photo and video collections, where
mtimeis commonly used for sorting and organization.Reported in: #1321
What was changed
The original approach of setting
copy_attributes = trueonfs_extraoptions was not possible —fs_extra1.3.0 does not have this field.fs_extrahas been removed from both crates and replaced with a stdlib-based implementation that correctly preserves attributes.czkawka_gui/src/connect_things/connect_button_move.rsfs_extra::dir::move_dirandfs_extra::file::move_filewith a custommove_item_preserving_attrsfunction.std::fs::rename— atomic, preserves all attributes with zero overhead.copy_item_preserving_attrs+ delete, which restores permissions and timestamps (mtime,atime) after copying.krokiet/src/file_actions/connect_move.rsfs_extra::dir::copyandfs_extra::file::copywith a customcopy_with_attrsfunction.std::fs::copy(preserves permissions on Unix) followed bystd::fs::FileTimesto restoremtimeandatime.czkawka_gui/Cargo.toml/krokiet/Cargo.tomlfs_extradependency from both crates.Expected behavior
When selected duplicate files or folders are moved or copied, their file attributes are preserved:
mtime) stays unchanged;atime) stays unchanged;Why this matters
Changing modification time during move operations breaks workflows where users rely on filesystem timestamps, for example: