From ded30a514072d9b40183aff2d3290bb34fbbd77f Mon Sep 17 00:00:00 2001 From: Salvador Cipolla Date: Sun, 15 Mar 2026 10:35:29 -0300 Subject: [PATCH 1/2] Add skip files extensions during filecopy of new mod version creation Also applies to folders starting with a period, as unix hidden folder convention. Customizable by editing the settings file. --- Knossos.NET/Classes/KnUtils.cs | 9 +++++++-- Knossos.NET/Models/GlobalSettings.cs | 8 ++++++-- .../ViewModels/Templates/Tasks/CreateModVersion.cs | 9 ++++++++- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Knossos.NET/Classes/KnUtils.cs b/Knossos.NET/Classes/KnUtils.cs index a97a435a..7b3d342b 100644 --- a/Knossos.NET/Classes/KnUtils.cs +++ b/Knossos.NET/Classes/KnUtils.cs @@ -402,12 +402,15 @@ public static void OpenFolder(string path) /// /// Async directory copy helper method /// Support optional recursive copy and progressCallback that informs the name of the current file that is being copied + /// Supports passing an optional array of extensions to ignore during file copy. + /// This also applies to folders starting with a "." (Unix hidden folder convention) /// /// /// /// /// /// + /// /// /// /// @@ -452,9 +455,11 @@ public static async Task CopyDirectoryAsync(string sourceDir, string desti { throw new TaskCanceledException(); } - + //Skip Unix convention hidden folder too if they match the skip extension list + if (subDir.Name.StartsWith(".") && ignoreExtensions != null && ignoreExtensions.Contains(subDir.Name.ToLower())) + continue; var newDestinationDir = Path.Combine(destinationDir, subDir.Name); - await CopyDirectoryAsync(subDir.FullName, newDestinationDir, true, cancelSource, progressCallback); + await CopyDirectoryAsync(subDir.FullName, newDestinationDir, true, cancelSource, progressCallback, ignoreExtensions); } } diff --git a/Knossos.NET/Models/GlobalSettings.cs b/Knossos.NET/Models/GlobalSettings.cs index 574e3815..d4f5c506 100644 --- a/Knossos.NET/Models/GlobalSettings.cs +++ b/Knossos.NET/Models/GlobalSettings.cs @@ -160,7 +160,7 @@ public StandaloneServerSettings(MultiCfg multiCfg, string id, string version, in [JsonPropertyName("close_to_tray")] public bool closeToTray { get { return _closeToTray; } - set { if (_closeToTray != value) { + set { if (_closeToTray != value) { _closeToTray = value; pendingChangesOnAppClose = true; } @@ -170,7 +170,10 @@ public bool closeToTray { public List ignoredLauncherUpdates { get; set; } = new List(); [JsonPropertyName("standalone_server_settings")] - public StandaloneServerSettings? standaloneServerSettings { get; set;} = null; + public StandaloneServerSettings? standaloneServerSettings { get; set; } = null; + + [JsonPropertyName("mod_filecopy_extension_skip")] + public List? skipExtensionsModFilecopy { get; set; } = new List() { ".svn", ".github", ".git", ".gitattributes", ".gitignore", ".md" }; /* * Settings that can wait to be saved at app close so we dont have to call save() all the time @@ -733,6 +736,7 @@ public void Load() MainWindowViewModel.Instance?.InstalledModsView?.ResetFilters(); } standaloneServerSettings = tempSettings.standaloneServerSettings; + skipExtensionsModFilecopy = tempSettings.skipExtensionsModFilecopy; ReadFS2IniValues(); Log.Add(Log.LogSeverity.Information, "GlobalSettings.Load()", "Global settings have been loaded"); diff --git a/Knossos.NET/ViewModels/Templates/Tasks/CreateModVersion.cs b/Knossos.NET/ViewModels/Templates/Tasks/CreateModVersion.cs index 765f32d7..60029960 100644 --- a/Knossos.NET/ViewModels/Templates/Tasks/CreateModVersion.cs +++ b/Knossos.NET/ViewModels/Templates/Tasks/CreateModVersion.cs @@ -4,6 +4,7 @@ using System.IO; using System.Threading.Tasks; using System.Threading; +using System.Linq; namespace Knossos.NET.ViewModels { @@ -59,7 +60,13 @@ public async Task CreateModVersion(Mod oldMod, string newVersion, Cancella writer.WriteLine("Warning: This token indicates an incomplete folder copy. If this token is present on the next KnossosNET startup this folder WILL BE DELETED."); } - await KnUtils.CopyDirectoryAsync(currentDir.FullName, newDir, true, cancellationTokenSource, copyCallback); + await KnUtils.CopyDirectoryAsync( + currentDir.FullName, + newDir, + true, + cancellationTokenSource, + copyCallback, + Knossos.globalSettings.skipExtensionsModFilecopy != null && Knossos.globalSettings.skipExtensionsModFilecopy.Any() ? Knossos.globalSettings.skipExtensionsModFilecopy.ToArray() : null); File.Delete(newDir + Path.DirectorySeparatorChar + "knossos_net_download.token"); From b5befed8e42fc1d160a4dcebf3c92188981d180c Mon Sep 17 00:00:00 2001 From: Salvador Cipolla Date: Sun, 15 Mar 2026 14:11:57 -0300 Subject: [PATCH 2/2] Skipp all unix convention hidden files during all folder copies --- Knossos.NET/Classes/KnUtils.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Knossos.NET/Classes/KnUtils.cs b/Knossos.NET/Classes/KnUtils.cs index 7b3d342b..6c25c9c0 100644 --- a/Knossos.NET/Classes/KnUtils.cs +++ b/Knossos.NET/Classes/KnUtils.cs @@ -403,7 +403,7 @@ public static void OpenFolder(string path) /// Async directory copy helper method /// Support optional recursive copy and progressCallback that informs the name of the current file that is being copied /// Supports passing an optional array of extensions to ignore during file copy. - /// This also applies to folders starting with a "." (Unix hidden folder convention) + /// Files and folders starting with a "." (Unix hidden folder convention) are skipped. /// /// /// @@ -436,6 +436,9 @@ public static async Task CopyDirectoryAsync(string sourceDir, string desti { throw new TaskCanceledException(); } + //Skip Unix convention hidden files + if (file.Name.StartsWith(".")) + continue; if (ignoreExtensions == null || !ignoreExtensions.Contains(file.Extension.ToLower())) { var targetFilePath = Path.Combine(destinationDir, file.Name); @@ -455,8 +458,8 @@ public static async Task CopyDirectoryAsync(string sourceDir, string desti { throw new TaskCanceledException(); } - //Skip Unix convention hidden folder too if they match the skip extension list - if (subDir.Name.StartsWith(".") && ignoreExtensions != null && ignoreExtensions.Contains(subDir.Name.ToLower())) + //Skip Unix convention hidden folder too + if (subDir.Name.StartsWith(".")) continue; var newDestinationDir = Path.Combine(destinationDir, subDir.Name); await CopyDirectoryAsync(subDir.FullName, newDestinationDir, true, cancelSource, progressCallback, ignoreExtensions);