Skip to content
Open
Show file tree
Hide file tree
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
12 changes: 10 additions & 2 deletions Knossos.NET/Classes/KnUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -402,12 +402,15 @@ public static void OpenFolder(string path)
/// <summary>
/// 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.
/// Files and folders starting with a "." (Unix hidden folder convention) are skipped.
/// </summary>
/// <param name="sourceDir"></param>
/// <param name="destinationDir"></param>
/// <param name="recursive"></param>
/// <param name="cancelSource"></param>
/// <param name="progressCallback"></param>
/// <param name="ignoreExtensions"></param>
/// <returns></returns>
/// <exception cref="DirectoryNotFoundException"></exception>
/// <exception cref="TaskCanceledException"></exception>
Expand All @@ -433,6 +436,9 @@ public static async Task<bool> 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);
Expand All @@ -452,9 +458,11 @@ public static async Task<bool> CopyDirectoryAsync(string sourceDir, string desti
{
throw new TaskCanceledException();
}

//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);
await CopyDirectoryAsync(subDir.FullName, newDestinationDir, true, cancelSource, progressCallback, ignoreExtensions);
}
}

Expand Down
8 changes: 6 additions & 2 deletions Knossos.NET/Models/GlobalSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -170,7 +170,10 @@ public bool closeToTray {
public List<string> ignoredLauncherUpdates { get; set; } = new List<string>();

[JsonPropertyName("standalone_server_settings")]
public StandaloneServerSettings? standaloneServerSettings { get; set;} = null;
public StandaloneServerSettings? standaloneServerSettings { get; set; } = null;

[JsonPropertyName("mod_filecopy_extension_skip")]
public List<string>? skipExtensionsModFilecopy { get; set; } = new List<string>() { ".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
Expand Down Expand Up @@ -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");

Expand Down
9 changes: 8 additions & 1 deletion Knossos.NET/ViewModels/Templates/Tasks/CreateModVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.IO;
using System.Threading.Tasks;
using System.Threading;
using System.Linq;

namespace Knossos.NET.ViewModels
{
Expand Down Expand Up @@ -59,7 +60,13 @@ public async Task<bool> 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");

Expand Down