mv -u silently skips an entire directory when the destination directory has an equal or newer timestamp

Đang mở Phù hợp với người mới
#17,003 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust
Lĩnh vực
backend, cli

Hướng nghiên cứu

Bắt đầu tại src/uu/mv/src/mv.rs, khoảng các dòng 827–838, nơi bước kiểm tra dấu thời gian trả về trước khi đổi tên, rồi so sánh hành vi này với quy tắc trong hướng dẫn sử dụng GNU mv dành cho thư mục nguồn. Thêm một kiểm thử hồi quy để tái hiện lỗi bằng một thư mục đích trống có dấu thời gian bằng hoặc mới hơn; xác minh rằng mv -u di chuyển các tệp nguồn và kết thúc thành công.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

When the destination is an existing empty directory with an equal or newer modification time, mv -u exits 0 but leaves the entire source directory in place. A script that pre-creates a staging directory can continue to packaging with all the files from the move missing.

Reproduction

Run once per implementation with the mv under test on PATH.

cd "$(mktemp -d)" || exit 1
export LC_ALL=C
mkdir -p release stage/release
printf 'package\n' > release/manifest
touch -d @1000000000 release
touch -d @1000000001 stage/release

mv -u release stage/
printf 'mv exit: %s\n' "$?"
find . -name manifest -print

Expected (GNU Coreutils 9.7 and 9.12)

mv exit: 0
./stage/release/manifest

Actual (uutils 0.13.0 and main)

mv exit: 0
./release/manifest

Neither implementation prints a diagnostic. With uutils, stage/release remains empty. The GNU mv manual limits the timestamp skip to non-directory sources.

Source

In mv.rs, lines 827–838, (!from_is_dir || to_metadata.is_dir()) is true when both entries are directories. If the source mtime is less than or equal to the destination mtime, the function returns Ok(()) before attempting the rename.

Tested on Debian 13, x86-64 Linux 6.18.57, with uutils 0.13.0 (07b76df), upstream main (2a072db), and GNU Coreutils 9.7 and 9.12. I found no matching issue or PR. The related PR #15912 addressed dangling destination symlinks.

Ngôn ngữ chính
Rust
Star
24.5k
Fork
2.2k
Merge trung bình
2 ngày 9 giờ
Pull request đã merge (30 ngày)
325

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của uutils/coreutils

Tất cả issue của uutils/coreutils

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.