Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,22 @@ public async Task<IEnumerable<SubModuleEstimation>> GetSubModuleEstimatedTimesAs
{
try
{
var name = Path.GetFileNameWithoutExtension(file.FullName).Split("-Sub-")[1];
var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(file.FullName);
var subIndex = fileNameWithoutExtension.IndexOf("-Sub-", StringComparison.Ordinal);

if (subIndex < 0)
{
// File doesn't match expected naming pattern - skip gracefully
return null;
}

var name = fileNameWithoutExtension[(subIndex + 5)..]; // 5 = length of "-Sub-"
var time = await GetEstimatedTimeAsync(file.FullName).ConfigureAwait(false);
return new SubModuleEstimation(name, time);
}
catch
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or System.Security.SecurityException)
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Catching only IOException is too narrow and may cause unhandled exceptions. The GetEstimatedTimeAsync method on line 53 can throw FormatException (from TimeSpan.Parse on line 83), and File.ReadAllTextAsync can throw other exceptions beyond IOException such as UnauthorizedAccessException, NotSupportedException, ArgumentException, etc. Since the SafeModuleEstimatedTimeProvider wrapper already catches all exceptions and logs them, it's safer to catch Exception here to prevent any parsing or I/O error from propagating.

Copilot uses AI. Check for mistakes.
{
File.Delete(file.FullName);
// File access error (locked, permissions, etc.) - skip gracefully without deleting
return null;
}
Comment on lines 41 to 60
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new error handling behavior lacks test coverage. Consider adding unit tests to verify that files are preserved when IOException occurs, when the file name format is invalid (no "-Sub-" pattern), and when GetEstimatedTimeAsync throws FormatException. This ensures the fix works as intended and prevents regression.

Copilot uses AI. Check for mistakes.
})
Expand Down
Loading