diff --git a/src/Tgstation.Server.Host/Components/Configuration.cs b/src/Tgstation.Server.Host/Components/Configuration.cs index ab24c9173d..8f759f906b 100644 --- a/src/Tgstation.Server.Host/Components/Configuration.cs +++ b/src/Tgstation.Server.Host/Components/Configuration.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Globalization; +using System.Linq; using System.Threading; using System.Threading.Tasks; using Tgstation.Server.Api.Models; @@ -42,7 +43,7 @@ namespace Tgstation.Server.Host.Components } /// - public async Task CopyDMFilesTo(string destination, CancellationToken cancellationToken) + public async Task CopyDMFilesTo(string dmeFile, string destination, CancellationToken cancellationToken) { //just assume no other fs race conditions here var dmeExistsTask = ioManager.FileExists(ioManager.ConcatPath(CodeModificationsSubdirectory, dmeFile), cancellationToken); @@ -77,6 +78,9 @@ namespace Tgstation.Server.Host.Components /// public Task> ListDirectory(string configurationRelativePath, ISystemIdentity systemIdentity, CancellationToken cancellationToken) { + if (String.IsNullOrEmpty(configurationRelativePath)) + configurationRelativePath = "."; + throw new NotImplementedException(); } diff --git a/src/Tgstation.Server.Host/Components/DreamMaker.cs b/src/Tgstation.Server.Host/Components/DreamMaker.cs index a55b2c1016..4f403b2797 100644 --- a/src/Tgstation.Server.Host/Components/DreamMaker.cs +++ b/src/Tgstation.Server.Host/Components/DreamMaker.cs @@ -191,7 +191,7 @@ namespace Tgstation.Server.Host.Components var dmePath = ioManager.ConcatPath(dirA, String.Concat(job.DmeName, DmeExtension)); var dmeReadTask = ioManager.ReadAllBytes(dmePath, cancellationToken); - var dmeModificationsTask = configuration.CopyDMFilesTo(ioManager.ResolvePath(dirA), cancellationToken); + var dmeModificationsTask = configuration.CopyDMFilesTo(dmePath, ioManager.ResolvePath(dirA), cancellationToken); var dmeBytes = await dmeReadTask.ConfigureAwait(false); var dme = Encoding.UTF8.GetString(dmeBytes); diff --git a/src/Tgstation.Server.Host/Components/IConfiguration.cs b/src/Tgstation.Server.Host/Components/IConfiguration.cs index 7cf71657cd..1f743dd4b8 100644 --- a/src/Tgstation.Server.Host/Components/IConfiguration.cs +++ b/src/Tgstation.Server.Host/Components/IConfiguration.cs @@ -14,10 +14,11 @@ namespace Tgstation.Server.Host.Components /// /// Copies all files in the CodeModifications directory to /// + /// The .dme file being compiled /// Path to the destination folder /// The for the operation /// A resulting in the if any - Task CopyDMFilesTo(string destination, CancellationToken cancellationToken); + Task CopyDMFilesTo(string dmeFile, string destination, CancellationToken cancellationToken); /// /// Symlinks all directories in the GameData directory to diff --git a/src/Tgstation.Server.Host/Core/DefaultIOManager.cs b/src/Tgstation.Server.Host/Core/DefaultIOManager.cs index a5c3d59eb7..900acc5cc4 100644 --- a/src/Tgstation.Server.Host/Core/DefaultIOManager.cs +++ b/src/Tgstation.Server.Host/Core/DefaultIOManager.cs @@ -220,5 +220,18 @@ namespace Tgstation.Server.Host.Core } return (IReadOnlyList)results; }, cancellationToken, TaskCreationOptions.LongRunning, TaskScheduler.Current); + + /// + public Task> GetFiles(string path, CancellationToken cancellationToken) => Task.Factory.StartNew(() => + { + path = ResolvePath(path); + var results = new List(); + foreach (var I in Directory.EnumerateFiles(path)) + { + cancellationToken.ThrowIfCancellationRequested(); + results.Add(I); + } + return (IReadOnlyList)results; + }, cancellationToken, TaskCreationOptions.LongRunning, TaskScheduler.Current); } } diff --git a/src/Tgstation.Server.Host/Core/IIOManager.cs b/src/Tgstation.Server.Host/Core/IIOManager.cs index 69a207e692..1ded3a21c7 100644 --- a/src/Tgstation.Server.Host/Core/IIOManager.cs +++ b/src/Tgstation.Server.Host/Core/IIOManager.cs @@ -72,6 +72,14 @@ namespace Tgstation.Server.Host.Core /// A resulting in the directories in Task> GetDirectories(string path, CancellationToken cancellationToken); + /// + /// Returns file names in a given + /// + /// The path to search for files + /// The for the operation + /// A resulting in the files in + Task> GetFiles(string path, CancellationToken cancellationToken); + /// /// Writes some to a file at overwriting previous content ///