Skip to content

Commit b2562f9

Browse files
thomhurstclaude
andauthored
fix: Stop deleting estimation files on transient errors (#1721)
* fix: Stop deleting estimation files on transient errors Fixes #1543 Changes: - Remove destructive File.Delete call that was triggered by any exception - Validate file name format before parsing (check for '-Sub-' presence) - Only catch IOException for transient errors (file locked, etc.) - Skip gracefully on any error instead of deleting potentially valid files The previous behavior would delete timing estimation files for transient errors like file locks, causing permanent loss of timing data. Files should only be overwritten by SaveSubModuleTimeAsync with correct data, not deleted on read errors. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: Expand exception handling to include permission errors Address review feedback - catch additional file access exceptions: - IOException (file locked, path too long, etc.) - UnauthorizedAccessException (access denied) - SecurityException (missing permissions) Uses exception filter pattern for clean multi-exception handling. --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent fba448b commit b2562f9

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

src/ModularPipelines/Engine/FileSystemModuleEstimatedTimeProvider.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,22 @@ public async Task<IEnumerable<SubModuleEstimation>> GetSubModuleEstimatedTimesAs
4040
{
4141
try
4242
{
43-
var name = Path.GetFileNameWithoutExtension(file.FullName).Split("-Sub-")[1];
43+
var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(file.FullName);
44+
var subIndex = fileNameWithoutExtension.IndexOf("-Sub-", StringComparison.Ordinal);
45+
46+
if (subIndex < 0)
47+
{
48+
// File doesn't match expected naming pattern - skip gracefully
49+
return null;
50+
}
51+
52+
var name = fileNameWithoutExtension[(subIndex + 5)..]; // 5 = length of "-Sub-"
4453
var time = await GetEstimatedTimeAsync(file.FullName).ConfigureAwait(false);
4554
return new SubModuleEstimation(name, time);
4655
}
47-
catch
56+
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or System.Security.SecurityException)
4857
{
49-
File.Delete(file.FullName);
58+
// File access error (locked, permissions, etc.) - skip gracefully without deleting
5059
return null;
5160
}
5261
})

0 commit comments

Comments
 (0)