diff --git a/src/ServerManagerDiscordBot/ServerManager.cs b/src/ServerManagerDiscordBot/ServerManager.cs index 6b59cda..5ba28f2 100644 --- a/src/ServerManagerDiscordBot/ServerManager.cs +++ b/src/ServerManagerDiscordBot/ServerManager.cs @@ -123,7 +123,7 @@ public async Task> GetServerFilesAsync(string name, Cancel var directory = new DirectoryInfo(server.FilesPath); if (!directory.Exists) { - throw new DirectoryNotFoundException($"The `{name}` server files directory `{server.FilesPath}` does not exist."); + directory.Create(); } var files = directory.EnumerateFiles(); @@ -161,7 +161,7 @@ public async Task> GetServerGalleryFilesAsync(string name, var directory = new DirectoryInfo(server.GalleryPath); if (!directory.Exists) { - throw new DirectoryNotFoundException($"The `{name}` server gallery directory `{server.GalleryPath}` does not exist."); + directory.Create(); } var files = directory.EnumerateFiles() @@ -179,6 +179,12 @@ public async Task UploadServerGalleryFileAsync(string name, string sourceUrl, st throw new InvalidOperationException($"The `{name}` server does not support this operation."); } + var directory = new DirectoryInfo(server.GalleryPath); + if (!directory.Exists) + { + directory.Create(); + } + if (!AppSettings.GalleryFileExtensions.Contains(Path.GetExtension(fileName).Substring(1), StringComparer.OrdinalIgnoreCase)) { throw new ArgumentException($"The gallery does not support the file type `{Path.GetExtension(fileName)}`.");