Unity-Technologies / Unity-Technologies/UnityDataTools
analyze truncates an existing -o database when the input matches no files
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- C#
- Estrellas
- 821
- Forks
- 71
- Merge medio
- 3 h 13 min
- PR fusionados (30 d)
- 9
Descripción
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.
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza en AnalyzerTool.Analyze, después de CollectFiles(), y revisa cómo la ruta sin archivos llega actualmente a la creación y finalización de la base de datos. Añade allí el manejo de la ausencia de archivos, decide si se debe compartir la redacción con el mensaje de #115 y verifica que una base de datos existente especificada con -o no se cree ni se trunque cuando ningún archivo de entrada coincida.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- csharp, sqlite
- Área
- cli, database
- Tipo de issue
- Error
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Estado de actividad
- Activo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 75/100