TeeJee.FileSystem.file_write() uses non-atomic delete + create, risking File exists collisions on rsync-log-changes
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 45/100
- issue の種類
- リファクタリング
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 領域
- backend
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- Vala
- スター
- 4.3k
- フォーク
- 162
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
linuxmint/timeshift のほかの issue
-
Delete snapshots: number mismatch対応中かも @EthanNoble が 6 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
-
難易度 1/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
-
難易度 3/5 半日 初心者へのやさしさ 55/100
linuxmint/timeshift の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
PixelPlayerHQ/PixelPlayerOSS#254 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
389ds/389-ds-base#8152 ·
メンテナーはふだん 2 日以内に返信
-
Bug feat:Syntax
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
ignatov/intellij-erlang#1342 ·
メンテナーはふだん 1 日以内に返信
-
intcomma returns exponential notation for large floats対応中かも @Omarinho12345 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
python-humanize/humanize#521 ·
メンテナーはふだん 1 日以内に返信
-
🧑💻 tech-debt
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
guibranco/gstraccini-bot-service#1206 ·
メンテナーはふだん 1 日以内に返信