Add some resource tests and other small changes (#638)

* Cleanup custom icon resources and add resource tests

* Don't delete old custom icons
This commit is contained in:
Josh 2023-01-20 00:18:57 -06:00 committed by GitHub
commit ace3678da7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 105 additions and 49 deletions

View file

@ -2,6 +2,7 @@
using Discord;
using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Files;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Levels;
using LBPUnion.ProjectLighthouse.Logging;
@ -227,14 +228,7 @@ public class PhotosController : ControllerBase
HashSet<string> photoResources = new(){photo.LargeHash, photo.SmallHash, photo.MediumHash, photo.PlanHash,};
foreach (string hash in photoResources)
{
if (System.IO.File.Exists(Path.Combine("png", $"{hash}.png")))
{
System.IO.File.Delete(Path.Combine("png", $"{hash}.png"));
}
if (System.IO.File.Exists(Path.Combine("r", hash)))
{
System.IO.File.Delete(Path.Combine("r", hash));
}
FileHelper.DeleteResource(hash);
}
this.database.Photos.Remove(photo);