From f1324f3de9f51c31fbe81734d9ae1ccc6f689546 Mon Sep 17 00:00:00 2001 From: Bitl Date: Sat, 25 Sep 2021 13:55:04 -0700 Subject: [PATCH] finally fucking fixed RenameFileWithInvalidChars --- .../StorageAndFunctions/GlobalFuncs.cs | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/Novetus/NovetusCore/StorageAndFunctions/GlobalFuncs.cs b/Novetus/NovetusCore/StorageAndFunctions/GlobalFuncs.cs index cf870f9..0b90633 100644 --- a/Novetus/NovetusCore/StorageAndFunctions/GlobalFuncs.cs +++ b/Novetus/NovetusCore/StorageAndFunctions/GlobalFuncs.cs @@ -1901,15 +1901,24 @@ public class GlobalFuncs public static void RenameFileWithInvalidChars(string path) { - if (!FileHasInvalidChars(path)) - return; + try + { + if (!FileHasInvalidChars(path)) + return; - string pathWithoutFilename = Path.GetDirectoryName(path); - string fileName = Path.GetFileName(path); - fileName = Regex.Replace(fileName, @"[^\w-.'_!()& ]", ""); - string finalPath = pathWithoutFilename + "\\" + fileName; + string pathWithoutFilename = Path.GetDirectoryName(path); + string fileName = Path.GetFileName(path); + fileName = Regex.Replace(fileName, @"[^\w-.'_!()& ]", ""); + string finalPath = pathWithoutFilename + "\\" + fileName; - FixedFileMove(path, finalPath, false); + FixedFileMove(path, finalPath, File.Exists(finalPath)); + } + catch (Exception ex) + { +#if LAUNCHER || CMD || URI + LogExceptions(ex); +#endif + } } #if LAUNCHER || CMD || URI