From d00b62c936e01922154bb320c30110917ce0e168 Mon Sep 17 00:00:00 2001 From: Dominion Date: Sun, 9 Oct 2022 10:18:52 -0400 Subject: [PATCH 1/8] Implements +x bit preservation on repo copy Closes #1167 --- .../Components/InstanceFactory.cs | 1 + .../Components/Repository/Repository.cs | 21 ++++++++++++- .../Repository/RepositoryManager.cs | 9 ++++++ .../Components/StaticFiles/Configuration.cs | 2 +- .../IO/DefaultIOManager.cs | 30 +++++++++++++++---- src/Tgstation.Server.Host/IO/IIOManager.cs | 8 ++++- .../IO/IPostWriteHandler.cs | 7 +++++ .../IO/PosixPostWriteHandler.cs | 18 ++++++++++- .../IO/WindowsPostWriteHandler.cs | 9 ++++++ .../IO/TestPostWriteHandler.cs | 4 +++ .../Tgstation.Server.Tests/IntegrationTest.cs | 1 + 11 files changed, 101 insertions(+), 9 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/InstanceFactory.cs b/src/Tgstation.Server.Host/Components/InstanceFactory.cs index 57a44f29b2..ff4fc85c11 100644 --- a/src/Tgstation.Server.Host/Components/InstanceFactory.cs +++ b/src/Tgstation.Server.Host/Components/InstanceFactory.cs @@ -251,6 +251,7 @@ namespace Tgstation.Server.Host.Components repositoryCommands, repoIoManager, eventConsumer, + postWriteHandler, gitRemoteFeaturesFactory, loggerFactory.CreateLogger(), loggerFactory.CreateLogger()); diff --git a/src/Tgstation.Server.Host/Components/Repository/Repository.cs b/src/Tgstation.Server.Host/Components/Repository/Repository.cs index 9990d584ce..9e0bea04f3 100644 --- a/src/Tgstation.Server.Host/Components/Repository/Repository.cs +++ b/src/Tgstation.Server.Host/Components/Repository/Repository.cs @@ -91,6 +91,11 @@ namespace Tgstation.Server.Host.Components.Repository /// readonly ICredentialsProvider credentialsProvider; + /// + /// The for the . + /// + readonly IPostWriteHandler postWriteHandler; + /// /// The for the . /// @@ -119,6 +124,7 @@ namespace Tgstation.Server.Host.Components.Repository /// The value of . /// The value of . /// The value of . + /// The value of . /// The to provide the value of . /// The value of . /// The value if . @@ -128,6 +134,7 @@ namespace Tgstation.Server.Host.Components.Repository IIOManager ioMananger, IEventConsumer eventConsumer, ICredentialsProvider credentialsProvider, + IPostWriteHandler postWriteHandler, IGitRemoteFeaturesFactory gitRemoteFeaturesFactory, ILogger logger, Action onDispose) @@ -137,6 +144,7 @@ namespace Tgstation.Server.Host.Components.Repository this.ioMananger = ioMananger ?? throw new ArgumentNullException(nameof(ioMananger)); this.eventConsumer = eventConsumer ?? throw new ArgumentNullException(nameof(eventConsumer)); this.credentialsProvider = credentialsProvider ?? throw new ArgumentNullException(nameof(credentialsProvider)); + this.postWriteHandler = postWriteHandler ?? throw new ArgumentNullException(nameof(postWriteHandler)); if (gitRemoteFeaturesFactory == null) throw new ArgumentNullException(nameof(gitRemoteFeaturesFactory)); @@ -500,7 +508,18 @@ namespace Tgstation.Server.Host.Components.Repository if (path == null) throw new ArgumentNullException(nameof(path)); logger.LogTrace("Copying to {0}...", path); - await ioMananger.CopyDirectory(ioMananger.ResolvePath(), path, new List { ".git" }, cancellationToken); + await ioMananger.CopyDirectory( + ioMananger.ResolvePath(), + path, + new List { ".git" }, + (src, dest) => + { + if (postWriteHandler.NeedsPostWrite(src)) + postWriteHandler.HandleWrite(dest); + + return Task.CompletedTask; + }, + cancellationToken); } /// diff --git a/src/Tgstation.Server.Host/Components/Repository/RepositoryManager.cs b/src/Tgstation.Server.Host/Components/Repository/RepositoryManager.cs index 46e3712f62..ba78fb23c5 100644 --- a/src/Tgstation.Server.Host/Components/Repository/RepositoryManager.cs +++ b/src/Tgstation.Server.Host/Components/Repository/RepositoryManager.cs @@ -42,6 +42,11 @@ namespace Tgstation.Server.Host.Components.Repository /// readonly IEventConsumer eventConsumer; + /// + /// The for the . + /// + readonly IPostWriteHandler postWriteHandler; + /// /// The for the . /// @@ -69,6 +74,7 @@ namespace Tgstation.Server.Host.Components.Repository /// The value of . /// The value of . /// The value of . + /// The value of . /// The value of . /// The value of . /// The value of . @@ -77,6 +83,7 @@ namespace Tgstation.Server.Host.Components.Repository ILibGit2Commands commands, IIOManager ioManager, IEventConsumer eventConsumer, + IPostWriteHandler postWriteHandler, IGitRemoteFeaturesFactory gitRemoteFeaturesFactory, ILogger repositoryLogger, ILogger logger) @@ -85,6 +92,7 @@ namespace Tgstation.Server.Host.Components.Repository this.commands = commands ?? throw new ArgumentNullException(nameof(commands)); this.ioManager = ioManager ?? throw new ArgumentNullException(nameof(ioManager)); this.eventConsumer = eventConsumer ?? throw new ArgumentNullException(nameof(eventConsumer)); + this.postWriteHandler = postWriteHandler ?? throw new ArgumentNullException(nameof(postWriteHandler)); this.gitRemoteFeaturesFactory = gitRemoteFeaturesFactory ?? throw new ArgumentNullException(nameof(gitRemoteFeaturesFactory)); this.repositoryLogger = repositoryLogger ?? throw new ArgumentNullException(nameof(repositoryLogger)); this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); @@ -206,6 +214,7 @@ namespace Tgstation.Server.Host.Components.Repository ioManager, eventConsumer, repositoryFactory, + postWriteHandler, gitRemoteFeaturesFactory, repositoryLogger, () => diff --git a/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs b/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs index 98d63bf5d8..7b84ce8ebf 100644 --- a/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs +++ b/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs @@ -180,7 +180,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles var dmeExistsTask = ioManager.FileExists(ioManager.ConcatPath(CodeModificationsSubdirectory, dmeFile), cancellationToken); var headFileExistsTask = ioManager.FileExists(ioManager.ConcatPath(CodeModificationsSubdirectory, CodeModificationsHeadFile), cancellationToken); var tailFileExistsTask = ioManager.FileExists(ioManager.ConcatPath(CodeModificationsSubdirectory, CodeModificationsTailFile), cancellationToken); - var copyTask = ioManager.CopyDirectory(CodeModificationsSubdirectory, destination, null, cancellationToken); + var copyTask = ioManager.CopyDirectory(CodeModificationsSubdirectory, destination, null, null, cancellationToken); await Task.WhenAll(dmeExistsTask, headFileExistsTask, tailFileExistsTask, copyTask); diff --git a/src/Tgstation.Server.Host/IO/DefaultIOManager.cs b/src/Tgstation.Server.Host/IO/DefaultIOManager.cs index bc46817039..ec198eea88 100644 --- a/src/Tgstation.Server.Host/IO/DefaultIOManager.cs +++ b/src/Tgstation.Server.Host/IO/DefaultIOManager.cs @@ -88,7 +88,12 @@ namespace Tgstation.Server.Host.IO } /// - public async Task CopyDirectory(string src, string dest, IEnumerable ignore, CancellationToken cancellationToken) + public async Task CopyDirectory( + string src, + string dest, + IEnumerable ignore, + Func postCopyCallback, + CancellationToken cancellationToken) { if (src == null) throw new ArgumentNullException(nameof(src)); @@ -97,7 +102,7 @@ namespace Tgstation.Server.Host.IO src = ResolvePath(src); dest = ResolvePath(dest); - foreach (var directoryCopy in CopyDirectoryImpl(src, dest, ignore, cancellationToken)) + foreach (var directoryCopy in CopyDirectoryImpl(src, dest, ignore, postCopyCallback, cancellationToken)) await directoryCopy; } @@ -368,9 +373,15 @@ namespace Tgstation.Server.Host.IO /// The source directory path. /// The destination directory path. /// Files and folders to ignore at the root level. + /// The optional callback called for each source/dest file pair post copy. /// The for the operation. /// A of s representing the running operation. - IEnumerable CopyDirectoryImpl(string src, string dest, IEnumerable ignore, CancellationToken cancellationToken) + IEnumerable CopyDirectoryImpl( + string src, + string dest, + IEnumerable ignore, + Func postCopyCallback, + CancellationToken cancellationToken) { var dir = new DirectoryInfo(src); var atLeastOneSubDir = false; @@ -378,7 +389,7 @@ namespace Tgstation.Server.Host.IO { if (ignore != null && ignore.Contains(subDirectory.Name)) continue; - foreach (var copyTask in CopyDirectoryImpl(subDirectory.FullName, Path.Combine(dest, subDirectory.Name), null, cancellationToken)) + foreach (var copyTask in CopyDirectoryImpl(subDirectory.FullName, Path.Combine(dest, subDirectory.Name), null, postCopyCallback, cancellationToken)) { atLeastOneSubDir = true; yield return copyTask; @@ -395,7 +406,16 @@ namespace Tgstation.Server.Host.IO { if (ignore != null && ignore.Contains(fileInfo.Name)) return; - tasks.Add(CopyFile(fileInfo.FullName, Path.Combine(dest, fileInfo.Name), cancellationToken)); + + async Task CopyThisFile() + { + var destFile = Path.Combine(dest, fileInfo.Name); + await CopyFile(fileInfo.FullName, destFile, cancellationToken); + if (postCopyCallback != null) + await postCopyCallback(fileInfo.FullName, destFile); + } + + tasks.Add(CopyThisFile()); } await Task.WhenAll(tasks); diff --git a/src/Tgstation.Server.Host/IO/IIOManager.cs b/src/Tgstation.Server.Host/IO/IIOManager.cs index 6f7dd75bbf..2e50ee317d 100644 --- a/src/Tgstation.Server.Host/IO/IIOManager.cs +++ b/src/Tgstation.Server.Host/IO/IIOManager.cs @@ -51,9 +51,15 @@ namespace Tgstation.Server.Host.IO /// The source directory path. /// The destination directory path. /// Files and folders to ignore at the root level. + /// The optional callback called for each source/dest file pair post copy. /// The for the operation. /// A representing the running operation. - Task CopyDirectory(string src, string dest, IEnumerable ignore, CancellationToken cancellationToken); + Task CopyDirectory( + string src, + string dest, + IEnumerable ignore, + Func postCopyCallback, + CancellationToken cancellationToken); /// /// Check that the file at exists. diff --git a/src/Tgstation.Server.Host/IO/IPostWriteHandler.cs b/src/Tgstation.Server.Host/IO/IPostWriteHandler.cs index e99a2eb1e4..9b21ab9ef8 100644 --- a/src/Tgstation.Server.Host/IO/IPostWriteHandler.cs +++ b/src/Tgstation.Server.Host/IO/IPostWriteHandler.cs @@ -5,6 +5,13 @@ /// interface IPostWriteHandler { + /// + /// Check if a given will need called on a copy of it. + /// + /// The path of the source file to check. + /// if should be called on copies of , otherwise. + public bool NeedsPostWrite(string sourceFilePath); + /// /// For handling system specific necessities after a write. /// diff --git a/src/Tgstation.Server.Host/IO/PosixPostWriteHandler.cs b/src/Tgstation.Server.Host/IO/PosixPostWriteHandler.cs index b2f9bf9143..26b1710212 100644 --- a/src/Tgstation.Server.Host/IO/PosixPostWriteHandler.cs +++ b/src/Tgstation.Server.Host/IO/PosixPostWriteHandler.cs @@ -25,6 +25,20 @@ namespace Tgstation.Server.Host.IO this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); } + /// + public bool NeedsPostWrite(string sourceFilePath) + { + if (sourceFilePath == null) + throw new ArgumentNullException(nameof(sourceFilePath)); + + if (Syscall.stat(sourceFilePath, out var stat) != 0) + throw new UnixIOException(Stdlib.GetLastError()); + + return stat.st_mode.HasFlag(FilePermissions.S_IXUSR) + || stat.st_mode.HasFlag(FilePermissions.S_IXOTH) + || stat.st_mode.HasFlag(FilePermissions.S_IXGRP); + } + /// public void HandleWrite(string filePath) { @@ -35,7 +49,9 @@ namespace Tgstation.Server.Host.IO if (Syscall.stat(filePath, out var stat) != 0) throw new UnixIOException(Stdlib.GetLastError()); - if (stat.st_mode.HasFlag(FilePermissions.S_IXUSR)) + if (stat.st_mode.HasFlag(FilePermissions.S_IXUSR) + || stat.st_mode.HasFlag(FilePermissions.S_IXOTH) + || stat.st_mode.HasFlag(FilePermissions.S_IXGRP)) { logger.LogTrace("{0} already +x", filePath); return; diff --git a/src/Tgstation.Server.Host/IO/WindowsPostWriteHandler.cs b/src/Tgstation.Server.Host/IO/WindowsPostWriteHandler.cs index bec6986208..76c4b0f9c6 100644 --- a/src/Tgstation.Server.Host/IO/WindowsPostWriteHandler.cs +++ b/src/Tgstation.Server.Host/IO/WindowsPostWriteHandler.cs @@ -7,6 +7,15 @@ namespace Tgstation.Server.Host.IO /// sealed class WindowsPostWriteHandler : IPostWriteHandler { + /// + public bool NeedsPostWrite(string sourceFilePath) + { + if (sourceFilePath == null) + throw new ArgumentNullException(nameof(sourceFilePath)); + + return false; + } + /// public void HandleWrite(string filePath) { diff --git a/tests/Tgstation.Server.Host.Tests/IO/TestPostWriteHandler.cs b/tests/Tgstation.Server.Host.Tests/IO/TestPostWriteHandler.cs index 40864bcba2..7a309c4455 100644 --- a/tests/Tgstation.Server.Host.Tests/IO/TestPostWriteHandler.cs +++ b/tests/Tgstation.Server.Host.Tests/IO/TestPostWriteHandler.cs @@ -48,12 +48,16 @@ namespace Tgstation.Server.Host.IO.Tests //ensure it is now executable File.WriteAllBytes(tmpFile, Encoding.UTF8.GetBytes("#!/bin/sh\n")); + Assert.IsFalse(postWriteHandler.NeedsPostWrite(tmpFile)); + using (var process = Process.Start(tmpFile)) { process.WaitForExit(); Assert.AreEqual(0, process.ExitCode); } + Assert.IsTrue(postWriteHandler.NeedsPostWrite(tmpFile)); + //run it again for the code coverage on that part where no changes are made if it's already executable postWriteHandler.HandleWrite(tmpFile); } diff --git a/tests/Tgstation.Server.Tests/IntegrationTest.cs b/tests/Tgstation.Server.Tests/IntegrationTest.cs index 7de3b4cdb4..09e7592142 100644 --- a/tests/Tgstation.Server.Tests/IntegrationTest.cs +++ b/tests/Tgstation.Server.Tests/IntegrationTest.cs @@ -1073,6 +1073,7 @@ namespace Tgstation.Server.Tests Mock.Of(), Mock.Of(), Mock.Of(), + Mock.Of(), Mock.Of(), Mock.Of>(), () => { }); From 086c215e005318dbba1a5d7a5144442a4cb0c6df Mon Sep 17 00:00:00 2001 From: Dominion Date: Sun, 9 Oct 2022 10:19:18 -0400 Subject: [PATCH 2/8] Performance improvement for directory copying --- src/Tgstation.Server.Host/IO/DefaultIOManager.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Tgstation.Server.Host/IO/DefaultIOManager.cs b/src/Tgstation.Server.Host/IO/DefaultIOManager.cs index ec198eea88..b3be8aa6f0 100644 --- a/src/Tgstation.Server.Host/IO/DefaultIOManager.cs +++ b/src/Tgstation.Server.Host/IO/DefaultIOManager.cs @@ -102,8 +102,7 @@ namespace Tgstation.Server.Host.IO src = ResolvePath(src); dest = ResolvePath(dest); - foreach (var directoryCopy in CopyDirectoryImpl(src, dest, ignore, postCopyCallback, cancellationToken)) - await directoryCopy; + await Task.WhenAll(CopyDirectoryImpl(src, dest, ignore, postCopyCallback, cancellationToken)); } /// From a57f032ce436d4561f2b9863d2170eae8d654474 Mon Sep 17 00:00:00 2001 From: Dominion Date: Sun, 9 Oct 2022 10:20:15 -0400 Subject: [PATCH 3/8] Version bump to 5.2.1 --- build/Version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/Version.props b/build/Version.props index c94784c13d..1b16b06328 100644 --- a/build/Version.props +++ b/build/Version.props @@ -3,7 +3,7 @@ - 5.2.0 + 5.2.1 4.4.0 9.7.0 10.1.0 From f72955cbc610317ea8538ff89a673fb9ba70f049 Mon Sep 17 00:00:00 2001 From: Dominion Date: Sun, 9 Oct 2022 10:30:55 -0400 Subject: [PATCH 4/8] Fix bad test case --- .../Tgstation.Server.Host.Tests/IO/TestPostWriteHandler.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/Tgstation.Server.Host.Tests/IO/TestPostWriteHandler.cs b/tests/Tgstation.Server.Host.Tests/IO/TestPostWriteHandler.cs index 7a309c4455..e5081ea7f4 100644 --- a/tests/Tgstation.Server.Host.Tests/IO/TestPostWriteHandler.cs +++ b/tests/Tgstation.Server.Host.Tests/IO/TestPostWriteHandler.cs @@ -40,24 +40,22 @@ namespace Tgstation.Server.Host.IO.Tests var tmpFile = Path.GetTempFileName(); try { + Assert.IsFalse(postWriteHandler.NeedsPostWrite(tmpFile)); postWriteHandler.HandleWrite(tmpFile); if (isWindows) return; //you do nothing //ensure it is now executable + Assert.IsTrue(postWriteHandler.NeedsPostWrite(tmpFile)); File.WriteAllBytes(tmpFile, Encoding.UTF8.GetBytes("#!/bin/sh\n")); - Assert.IsFalse(postWriteHandler.NeedsPostWrite(tmpFile)); - using (var process = Process.Start(tmpFile)) { process.WaitForExit(); Assert.AreEqual(0, process.ExitCode); } - Assert.IsTrue(postWriteHandler.NeedsPostWrite(tmpFile)); - //run it again for the code coverage on that part where no changes are made if it's already executable postWriteHandler.HandleWrite(tmpFile); } From 26acc4a0350ac6d541eeab6c5790f3bd33421af9 Mon Sep 17 00:00:00 2001 From: Dominion Date: Sun, 9 Oct 2022 10:41:21 -0400 Subject: [PATCH 5/8] Additional null check for code coverage --- tests/Tgstation.Server.Host.Tests/IO/TestPostWriteHandler.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Tgstation.Server.Host.Tests/IO/TestPostWriteHandler.cs b/tests/Tgstation.Server.Host.Tests/IO/TestPostWriteHandler.cs index e5081ea7f4..8c6e1cbaef 100644 --- a/tests/Tgstation.Server.Host.Tests/IO/TestPostWriteHandler.cs +++ b/tests/Tgstation.Server.Host.Tests/IO/TestPostWriteHandler.cs @@ -24,6 +24,7 @@ namespace Tgstation.Server.Host.IO.Tests postWriteHandler = new PosixPostWriteHandler(Mock.Of>()); Assert.ThrowsException(() => postWriteHandler.HandleWrite(null)); + Assert.ThrowsException(() => postWriteHandler.NeedsPostWrite(null)); } [TestMethod] From 6514b03039c0b265a68e74548c2f5c9e580ea24e Mon Sep 17 00:00:00 2001 From: Dominion Date: Sun, 9 Oct 2022 11:01:12 -0400 Subject: [PATCH 6/8] I was right the first time --- src/Tgstation.Server.Host/IO/PosixPostWriteHandler.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Tgstation.Server.Host/IO/PosixPostWriteHandler.cs b/src/Tgstation.Server.Host/IO/PosixPostWriteHandler.cs index 26b1710212..a69f77ac74 100644 --- a/src/Tgstation.Server.Host/IO/PosixPostWriteHandler.cs +++ b/src/Tgstation.Server.Host/IO/PosixPostWriteHandler.cs @@ -34,9 +34,7 @@ namespace Tgstation.Server.Host.IO if (Syscall.stat(sourceFilePath, out var stat) != 0) throw new UnixIOException(Stdlib.GetLastError()); - return stat.st_mode.HasFlag(FilePermissions.S_IXUSR) - || stat.st_mode.HasFlag(FilePermissions.S_IXOTH) - || stat.st_mode.HasFlag(FilePermissions.S_IXGRP); + return stat.st_mode.HasFlag(FilePermissions.S_IXUSR); } /// @@ -49,9 +47,7 @@ namespace Tgstation.Server.Host.IO if (Syscall.stat(filePath, out var stat) != 0) throw new UnixIOException(Stdlib.GetLastError()); - if (stat.st_mode.HasFlag(FilePermissions.S_IXUSR) - || stat.st_mode.HasFlag(FilePermissions.S_IXOTH) - || stat.st_mode.HasFlag(FilePermissions.S_IXGRP)) + if (stat.st_mode.HasFlag(FilePermissions.S_IXUSR)) { logger.LogTrace("{0} already +x", filePath); return; From 5224225c2b1bd7acfddcec00d67add214d31d1fd Mon Sep 17 00:00:00 2001 From: Dominion Date: Sun, 9 Oct 2022 12:48:10 -0400 Subject: [PATCH 7/8] Minor cleanups --- .../IO/DefaultIOManager.cs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Tgstation.Server.Host/IO/DefaultIOManager.cs b/src/Tgstation.Server.Host/IO/DefaultIOManager.cs index b3be8aa6f0..d8fc426270 100644 --- a/src/Tgstation.Server.Host/IO/DefaultIOManager.cs +++ b/src/Tgstation.Server.Host/IO/DefaultIOManager.cs @@ -386,13 +386,12 @@ namespace Tgstation.Server.Host.IO var atLeastOneSubDir = false; foreach (var subDirectory in dir.EnumerateDirectories()) { + atLeastOneSubDir = true; + if (ignore != null && ignore.Contains(subDirectory.Name)) continue; foreach (var copyTask in CopyDirectoryImpl(subDirectory.FullName, Path.Combine(dest, subDirectory.Name), null, postCopyCallback, cancellationToken)) - { - atLeastOneSubDir = true; yield return copyTask; - } } async Task CopyThisDirectory() @@ -400,24 +399,26 @@ namespace Tgstation.Server.Host.IO if (!atLeastOneSubDir) await CreateDirectory(dest, cancellationToken); // save on createdir calls - var tasks = new List(); + var fileCopyTasks = new List(); foreach (var fileInfo in dir.EnumerateFiles()) { if (ignore != null && ignore.Contains(fileInfo.Name)) return; + var sourceFile = fileInfo.FullName; + var destFile = Path.Combine(dest, fileInfo.Name); + async Task CopyThisFile() { - var destFile = Path.Combine(dest, fileInfo.Name); - await CopyFile(fileInfo.FullName, destFile, cancellationToken); + await CopyFile(sourceFile, destFile, cancellationToken); if (postCopyCallback != null) - await postCopyCallback(fileInfo.FullName, destFile); + await postCopyCallback(sourceFile, destFile); } - tasks.Add(CopyThisFile()); + fileCopyTasks.Add(CopyThisFile()); } - await Task.WhenAll(tasks); + await Task.WhenAll(fileCopyTasks); } yield return CopyThisDirectory(); From 58ce08879572c61e6ffcdf5c817bbc92734d1716 Mon Sep 17 00:00:00 2001 From: Dominion Date: Sun, 9 Oct 2022 13:30:18 -0400 Subject: [PATCH 8/8] I give up, play it safe --- src/Tgstation.Server.Host/IO/DefaultIOManager.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Tgstation.Server.Host/IO/DefaultIOManager.cs b/src/Tgstation.Server.Host/IO/DefaultIOManager.cs index d8fc426270..2fd09a6d07 100644 --- a/src/Tgstation.Server.Host/IO/DefaultIOManager.cs +++ b/src/Tgstation.Server.Host/IO/DefaultIOManager.cs @@ -383,11 +383,8 @@ namespace Tgstation.Server.Host.IO CancellationToken cancellationToken) { var dir = new DirectoryInfo(src); - var atLeastOneSubDir = false; foreach (var subDirectory in dir.EnumerateDirectories()) { - atLeastOneSubDir = true; - if (ignore != null && ignore.Contains(subDirectory.Name)) continue; foreach (var copyTask in CopyDirectoryImpl(subDirectory.FullName, Path.Combine(dest, subDirectory.Name), null, postCopyCallback, cancellationToken)) @@ -396,8 +393,7 @@ namespace Tgstation.Server.Host.IO async Task CopyThisDirectory() { - if (!atLeastOneSubDir) - await CreateDirectory(dest, cancellationToken); // save on createdir calls + await CreateDirectory(dest, cancellationToken); var fileCopyTasks = new List(); foreach (var fileInfo in dir.EnumerateFiles())