Unity-Technologies / Unity-Technologies/UnityDataTools
analyze truncates an existing -o database when the input matches no files
まだ誰も着手していません。
- 主要言語
- C#
- スター
- 821
- フォーク
- 71
- 平均マージ
- 3時間 13分
- マージ済み PR(30日)
- 9
説明
When the input paths match no files at all, analyze still creates the output database before
discovering there is nothing to do. SQLiteWriter.Begin truncates the file (File.WriteAllBytes)
and runs the full schema init, the run then finds zero files, and the (now empty) database is
deleted.
The destructive part is the truncation. A mistyped path is enough:
UnityDataTool analyze C:/typo/not-a-real-path -o important.db
important.db is a previous, valid analysis. The command prints
Warning: path not found, skipping: C:/typo/not-a-real-path, truncates important.db anyway, and
(since #115) deletes it. The old content is gone either way — this behaviour predates #115, which
only changed what is left behind afterwards.
Nothing needs to touch the filesystem in this case. A check before the database is created, e.g.
after CollectFiles() in AnalyzerTool.Analyze:
if (files.Count == 0)
{
Console.Error.WriteLine("Error: the input paths matched no files to analyze.");
return 1;
}
avoids creating or truncating anything, and skips the schema init and finalize work that is
currently thrown away.
Points to decide:
- This introduces a second "nothing was analyzed" message alongside the one added in #115. They
could share wording. - It also makes an existing database at
-osurvive this class of failure, while a run where every
file failed still deletes it. That difference is defensible (the file is only removed once its
content has already been destroyed) but it should be a deliberate choice.
Found while reviewing the fix for #115; left out of that PR to keep it to a single failure path.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
AnalyzerTool.Analyze の CollectFiles() の後の箇所から始め、現在ファイルがないパスがデータベースの作成と完了処理にどのように到達するかを確認します。そこでファイルがない場合の処理を追加し、#115 のメッセージと文言を共有するかどうかを判断し、入力ファイルに一致するものがない場合に既存の -o データベースが作成または切り詰められないことを検証します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- csharp, sqlite
- 領域
- cli, database
- issue の種類
- バグ
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 活発
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 75/100