Compare commits

...

2 Commits

Author SHA1 Message Date
copilot-swe-agent[bot]
19bba7f229 Fix illegal path characters error in InfoPanel with defensive programming
Co-authored-by: emako <24737061+emako@users.noreply.github.com>
2025-08-08 15:07:53 +00:00
copilot-swe-agent[bot]
7a05793bf7 Initial plan 2025-08-08 15:00:33 +00:00

View File

@@ -58,16 +58,50 @@ public partial class InfoPanel : UserControl
Dispatcher.BeginInvoke(new Action(() => image.Source = source));
});
var name = Path.GetFileName(path);
string name;
try
{
name = Path.GetFileName(path);
}
catch (ArgumentException)
{
// Handle invalid path characters gracefully
name = path;
}
catch (PathTooLongException)
{
// Handle path too long scenarios
name = path;
}
filename.Text = string.IsNullOrEmpty(name) ? path : name;
try
{
var last = File.GetLastWriteTime(path);
modDate.Text = string.Format(TranslationHelper.Get("InfoPanel_LastModified"),
last.ToString(CultureInfo.CurrentCulture));
}
catch (ArgumentException)
{
// Handle invalid path characters gracefully
modDate.Text = TranslationHelper.Get("InfoPanel_LastModified_Unavailable") ?? "Last modified: Unavailable";
}
catch (UnauthorizedAccessException)
{
// Handle access denied scenarios
modDate.Text = TranslationHelper.Get("InfoPanel_LastModified_Unavailable") ?? "Last modified: Unavailable";
}
catch (PathTooLongException)
{
// Handle path too long scenarios
modDate.Text = TranslationHelper.Get("InfoPanel_LastModified_Unavailable") ?? "Last modified: Unavailable";
}
Stop = false;
_ = Task.Run(() =>
{
try
{
if (File.Exists(path))
{
@@ -117,6 +151,22 @@ public partial class InfoPanel : UserControl
$"{totalSizeL.ToPrettySize(2)} {t}";
});
}
}
catch (ArgumentException)
{
// Handle invalid path characters gracefully
Dispatcher.Invoke(() => { totalSize.Text = "Size: Unavailable"; });
}
catch (UnauthorizedAccessException)
{
// Handle access denied scenarios
Dispatcher.Invoke(() => { totalSize.Text = "Size: Unavailable"; });
}
catch (PathTooLongException)
{
// Handle path too long scenarios
Dispatcher.Invoke(() => { totalSize.Text = "Size: Unavailable"; });
}
});
}
}