Dropped the initial commit for this work due to a large file. Had to do some cleanup from a bad merge.

This commit is contained in:
Joseph Milazzo 2021-03-23 12:27:04 -05:00
parent 931ecb1437
commit f63c38ac23
6 changed files with 9 additions and 7 deletions

View File

@ -28,6 +28,7 @@
<PackageReference Include="NetVips" Version="1.2.4" />
<PackageReference Include="NetVips.Native" Version="8.10.5.1" />
<PackageReference Include="NReco.Logging.File" Version="1.1.1" />
<PackageReference Include="SharpCompress" Version="0.28.1" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.16.0.25740">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

View File

@ -5,6 +5,7 @@ using System.Threading.Tasks;
using API.Extensions;
using API.Interfaces;
using API.Interfaces.Services;
using API.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
@ -68,7 +69,7 @@ namespace API.Controllers
}
var fileBytes = await _directoryService.ReadFileAsync(zipPath);
_directoryService.ClearAndDeleteDirectory(tempLocation);
DirectoryService.ClearAndDeleteDirectory(tempLocation);
(new FileInfo(zipPath)).Delete();
return File(fileBytes, "application/zip", Path.GetFileName(zipPath));

View File

@ -95,7 +95,7 @@ namespace API.Services
/// Deletes all files within the directory, then the directory itself.
/// </summary>
/// <param name="directoryPath"></param>
public void ClearAndDeleteDirectory(string directoryPath)
public static void ClearAndDeleteDirectory(string directoryPath)
{
DirectoryInfo di = new DirectoryInfo(directoryPath);
@ -109,7 +109,7 @@ namespace API.Services
/// </summary>
/// <param name="directoryPath"></param>
/// <returns></returns>
public void ClearDirectory(string directoryPath)
public static void ClearDirectory(string directoryPath)
{
var di = new DirectoryInfo(directoryPath);
if (!di.Exists) return;

View File

@ -100,7 +100,7 @@ namespace API.Services
public void CleanupTemp()
{
var tempDirectory = Path.Join(Directory.GetCurrentDirectory(), "temp");
BackgroundJob.Enqueue((() => _directoryService.ClearDirectory(tempDirectory)));
BackgroundJob.Enqueue((() => DirectoryService.ClearDirectory(tempDirectory)));
}
public void BackupDatabase()

View File

@ -82,7 +82,7 @@ namespace API.Services.Tasks
var tempDirectory = Path.Join(_tempDirectory, dateString);
DirectoryService.ExistOrCreate(tempDirectory);
_directoryService.ClearDirectory(tempDirectory);
DirectoryService.ClearDirectory(tempDirectory);
_directoryService.CopyFilesToDirectory(
_backupFiles.Select(file => Path.Join(Directory.GetCurrentDirectory(), file)).ToList(), tempDirectory);
@ -95,7 +95,7 @@ namespace API.Services.Tasks
_logger.LogError(ex, "There was an issue when archiving library backup");
}
_directoryService.ClearAndDeleteDirectory(tempDirectory);
DirectoryService.ClearAndDeleteDirectory(tempDirectory);
_logger.LogInformation("Database backup completed");
}

View File

@ -26,7 +26,7 @@ namespace API.Services.Tasks
{
_logger.LogInformation("Cleaning temp directory");
var tempDirectory = Path.Join(Directory.GetCurrentDirectory(), "temp");
_directoryService.ClearDirectory(tempDirectory);
DirectoryService.ClearDirectory(tempDirectory);
_logger.LogInformation("Cleaning cache directory");
_cacheService.Cleanup();
_logger.LogInformation("Cleaning old database backups");