Merge pull request #1490 from Mbucari/master

Two bugfixes
This commit is contained in:
rmcrackan
2025-12-09 13:39:14 -05:00
committed by GitHub
2 changed files with 11 additions and 7 deletions

View File

@@ -56,15 +56,18 @@ namespace FileManager
fileExtension = GetStandardizedExtension(fileExtension);
// remove invalid chars
path = GetSafePath(path, replacements);
var pathStr = removeInvalidWhitespace(path.Path);
var pathWithoutExtension = pathStr.EndsWithInsensitive(fileExtension)
? pathStr[..^fileExtension.Length]
: path.Path;
// remove invalid chars, but leave file extension untouched
pathWithoutExtension = GetSafePath(pathWithoutExtension, replacements);
// ensure uniqueness and check lengths
var dir = Path.GetDirectoryName(path)?.TruncateFilename(LongPath.MaxDirectoryLength) ?? string.Empty;
var dir = Path.GetDirectoryName(pathWithoutExtension)?.TruncateFilename(LongPath.MaxDirectoryLength) ?? string.Empty;
var fileName = Path.GetFileName(path);
var extIndex = fileName.LastIndexOf(fileExtension, StringComparison.OrdinalIgnoreCase);
var filenameWithoutExtension = extIndex >= 0 ? fileName.Remove(extIndex, fileExtension.Length) : fileName;
var filenameWithoutExtension = Path.GetFileName(pathWithoutExtension);
var fileStem
= Path.Combine(dir, filenameWithoutExtension.TruncateFilename(LongPath.MaxFilenameLength - fileExtension.Length))
.TruncateFilename(LongPath.MaxPathLength - fileExtension.Length);

View File

@@ -90,6 +90,7 @@ namespace LibationAvalonia
/// <param name="caption">The text to display in the title bar of the message box.</param>
/// <param name="exception">Exception to log.</param>
public static async Task ShowAdminAlert(Window? owner, string text, string caption, Exception exception)
=> await Dispatcher.UIThread.InvokeAsync(async () =>
{
// for development and debugging, show me what broke!
if (System.Diagnostics.Debugger.IsAttached)
@@ -105,7 +106,7 @@ namespace LibationAvalonia
var form = new MessageBoxAlertAdminDialog(text, caption, exception);
await DisplayWindow(form, owner);
}
});
private static async Task<DialogResult> ShowCoreAsync(Window? owner, string message, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, bool saveAndRestorePosition = true)
=> await Dispatcher.UIThread.InvokeAsync(async () =>