Unity-Technologies / Unity-Technologies/UnityDataTools
analyze truncates an existing -o database when the input matches no files
Personne n'a encore pris cette issue.
- Langage dominant
- C#
- Étoiles
- 821
- Forks
- 71
- Merge moyen
- 3 h 13 min
- PR mergées (30 j)
- 9
Description
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.
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez dans AnalyzerTool.Analyze, au point situé après CollectFiles(), et examinez comment le chemin sans fichiers atteint actuellement la création et la finalisation de la base de données. Ajoutez-y la gestion de l’absence de fichiers, déterminez s’il faut reprendre la formulation du message de #115 et vérifiez qu’une base de données existante indiquée avec -o n’est ni créée ni tronquée lorsqu’aucun fichier d’entrée ne correspond.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- csharp, sqlite
- Domaine
- cli, database
- Type d'issue
- Bug
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Activité
- Active
- Clarté
- Plutôt claire
- Accessibilité débutants
- 75/100