cp: clean existing file when copy from stream#8149
Conversation
3f5ab10 to
0470254
Compare
This comment was marked as resolved.
This comment was marked as resolved.
|
GNU testsuite comparison: |
src/uu/cp/src/platform/other_unix.rs
Outdated
| .open(dest)?; | ||
|
|
||
| let dest_filetype = dst_file.metadata()?.file_type(); | ||
| let dest_is_stream = dest_filetype.is_fifo() |
There was a problem hiding this comment.
seems that the code is duplicated, could you please move that into a function? thanks
This comment was marked as resolved.
This comment was marked as resolved.
src/uu/cp/src/cp.rs
Outdated
| #[cfg(unix)] | ||
| let source_is_stream = | ||
| file_type.is_fifo() || file_type.is_char_device() || file_type.is_block_device(); | ||
| #[cfg(not(unix))] | ||
| let source_is_stream = false; | ||
|
|
||
| source_is_stream |
There was a problem hiding this comment.
you can probably do:
| #[cfg(unix)] | |
| let source_is_stream = | |
| file_type.is_fifo() || file_type.is_char_device() || file_type.is_block_device(); | |
| #[cfg(not(unix))] | |
| let source_is_stream = false; | |
| source_is_stream | |
| #[cfg(unix)] | |
| file_type.is_fifo() || file_type.is_char_device() || file_type.is_block_device() | |
| #[cfg(not(unix))] | |
| false |
There was a problem hiding this comment.
I got diagnostic:
attributes on expressions are experimental
see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information
add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable
this compiler was built on 2025-04-26; consider upgrading it if it is out of date
There was a problem hiding this comment.
ok, please ignore me then :)
|
GNU testsuite comparison: |
|
Is there any description for this line? coreutils/src/uu/cp/src/platform/other_unix.rs Lines 54 to 56 in f111113 edit: According to my tests, GNU cp doesn't reset target's permission just because the source is fifo, so I just remove these lines. |
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
4f6be64 to
7396d17
Compare
|
GNU testsuite comparison: |
7396d17 to
1d175f3
Compare
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
|
Thanks! |
fixes #7885
copy_streamdoesn't clear the dest file, if dest is not a stream, clear it manually.