From c75dd215511b9c17eed44a6750ee6dabf5d94019 Mon Sep 17 00:00:00 2001 From: Davide Grilli Date: Thu, 17 Sep 2026 16:19:37 +0200 Subject: [PATCH] Exclude temp_* root folders from the CAD index temp_paris, temp_davide, temp_studi esterni and the other temp_* folders are personal/scratch work areas on the share: they hold stale or unrelated copies of codes that also exist in the official project folders, and a real .asm can numerically coincide with an unrelated file living in one of these (see docs/formato-asm.md, the 2502020809 false-positive pulling in an unrelated machine's assembly from temp_studi esterni/Slitter CD549). Scan now deletes any already-indexed temp_* rows up front and skips walking those folders going forward, so downstream queries (Form1.cs, ExtractCreoStrings.cs) never need to filter them out case by case. Co-Authored-By: Claude Sonnet 5 --- CadSearchGui/Indexer.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/CadSearchGui/Indexer.cs b/CadSearchGui/Indexer.cs index e04bc1e..c7c74c6 100644 --- a/CadSearchGui/Indexer.cs +++ b/CadSearchGui/Indexer.cs @@ -65,9 +65,25 @@ public static class Indexer schemaCmd.ExecuteNonQuery(); } + // Le cartelle "temp_*" (temp_paris, temp_davide, temp_studi esterni, ...) sono lavori + // personali/temporanei: contengono spesso copie datate o versioni scollegate di codici + // che esistono ANCHE nel resto della share, con lo stesso codice ma contenuto diverso. + // Un .asm nella struttura "ufficiale" può referenziare per coincidenza numerica un file + // dentro una di queste cartelle (vedi docs/formato-asm.md, falso positivo su + // "2502020809"), trascinando dentro un intero assieme di un progetto scollegato. Vanno + // escluse a monte, non solo filtrate caso per caso nelle singole query. + using (var deleteTempCmd = connection.CreateCommand()) + { + deleteTempCmd.CommandText = @"DELETE FROM files WHERE cartella_radice LIKE 'temp\_%' ESCAPE '\'"; + deleteTempCmd.ExecuteNonQuery(); + } + // Indicizza tutte le cartelle di primo livello sotto la radice (non un elenco fisso), // così una nuova cartella creata sulla share entra nell'indice senza modificare il codice. - var cartelleRadice = Directory.GetDirectories(root).Select(p => Path.GetFileName(p)!).ToArray(); + var cartelleRadice = Directory.GetDirectories(root) + .Select(p => Path.GetFileName(p)!) + .Where(c => !c.StartsWith("temp_", StringComparison.OrdinalIgnoreCase)) + .ToArray(); var previsti = new Dictionary(); foreach (var cartella in cartelleRadice)