Unity-Technologies / Unity-Technologies/UnityDataTools
analyze truncates an existing -o database when the input matches no files
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- C#
- Star
- 821
- Fork
- 71
- Merge trung bình
- 3 giờ 13 phút
- Pull request đã merge (30 ngày)
- 9
Mô tả
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.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
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.
Hướng nghiên cứu
Bắt đầu trong AnalyzerTool.Analyze, tại điểm sau CollectFiles(), và xem xét cách đường dẫn không có tệp hiện đi đến việc tạo và hoàn tất cơ sở dữ liệu. Thêm xử lý không có tệp tại đó, quyết định có dùng chung cách diễn đạt với thông báo từ #115 hay không, và xác minh rằng cơ sở dữ liệu hiện có được chỉ định bằng -o không bị tạo hoặc cắt ngắn khi không có tệp đầu vào nào khớp.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- csharp, sqlite
- Lĩnh vực
- cli, database
- Loại issue
- Lỗi
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức độ hoạt động
- Sôi nổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 75/100