TeeJee.FileSystem.file_write() uses non-atomic delete + create, risking File exists collisions on rsync-log-changes
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Tái cấu trúc
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- backend
Hướng nghiên cứu
Start with file_write() in src/Utility/TeeJee.FileSystem.vala (around lines 165-185) and the finish_called flag in src/Utility/AsyncTask.vala (around lines 295-298), then check the callers RsyncTask.finish_task() and RsyncTask.parse_log(). Confirm whether replacing the delete-then-create sequence with an atomic replace preserves the current behaviour for existing callers. Done means both spots are hardened without changing results, which needs confirmation from a maintainer since the issue is a proposal rather than a reproduced bug.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
While investigating Error opening file ".../rsync-log-changes": File exists during fast rsync snapshot runs on Timeshift 25.12.4, I found that the primary trigger was the dual-thread finish() race fixed in #552 (c112e86).
However, inspecting src/Utility/TeeJee.FileSystem.vala and src/Utility/AsyncTask.vala after #552 shows two remaining defensive edge cases that could still allow File exists errors or non-atomic writes if file_write() or finish() is ever invoked concurrently:
1. Non-atomic file_write() (src/Utility/TeeJee.FileSystem.vala:165-185)
Currently, file_write() performs a separate existence check, delete, and FileCreateFlags.NONE creation:
var file = File.new_for_path (file_path);
if (file.query_exists ()) {
file.delete ();
}
var file_stream = file.create (FileCreateFlags.NONE);
If two callers (such as RsyncTask.finish_task() and RsyncTask.parse_log()) ever target the same path concurrently—or if a snapshot is interrupted mid-write—this TOCTOU sequence can fail with File exists or leave a truncated rsync-log-changes file.
Using file.replace(null, false, FileCreateFlags.REPLACE_DESTINATION) (or File.replace_contents()) would make file_write() atomic and eliminate File exists collisions across all callers.
2. Non-atomic finish_called guard (src/Utility/AsyncTask.vala:295-298)
#552 cleanly serializes finish() via wait_and_finish(), so there is currently only one caller. Hardening finish_called with GLib.AtomicInt (e.g., AtomicInt.compare_and_exchange(ref finish_called, 0, 1)) would ensure finish() remains thread-safe if any subclass or future change ever calls it directly.
Environment
- Timeshift 25.12.4 (Linux Mint 22.3) running on an older Apple iMac
- An external FireWire drive is the snapshot target where
rsynccompletes in ~35s if no major changes have been made
- Ngôn ngữ chính
- Vala
- Star
- 4.3k
- Fork
- 162
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của linuxmint/timeshift
-
Delete snapshots: number mismatchCó thể đã có người làm @EthanNoble đã nhận 6 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 78/100
-
License parsing with GitHubĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
-
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 55/100
Tất cả issue của linuxmint/timeshift
Issue tương tự
-
api beginner story
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
NCSU-App-Development-Club/ios_fall_26#86 ·
Maintainer thường phản hồi trong vòng 4 ngày
-
都道府県を指定すると区名から始まる住所に市名を補わないĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
digital-go-jp/abr-geocoder#457 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
pearu/agent-sandbox#422 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
OpenPrinting/cups#1826 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày