mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-07-09 03:04:19 -04:00
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:
parent
931ecb1437
commit
f63c38ac23
@ -28,6 +28,7 @@
|
|||||||
<PackageReference Include="NetVips" Version="1.2.4" />
|
<PackageReference Include="NetVips" Version="1.2.4" />
|
||||||
<PackageReference Include="NetVips.Native" Version="8.10.5.1" />
|
<PackageReference Include="NetVips.Native" Version="8.10.5.1" />
|
||||||
<PackageReference Include="NReco.Logging.File" Version="1.1.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">
|
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.16.0.25740">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
@ -5,6 +5,7 @@ using System.Threading.Tasks;
|
|||||||
using API.Extensions;
|
using API.Extensions;
|
||||||
using API.Interfaces;
|
using API.Interfaces;
|
||||||
using API.Interfaces.Services;
|
using API.Interfaces.Services;
|
||||||
|
using API.Services;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
@ -68,7 +69,7 @@ namespace API.Controllers
|
|||||||
}
|
}
|
||||||
var fileBytes = await _directoryService.ReadFileAsync(zipPath);
|
var fileBytes = await _directoryService.ReadFileAsync(zipPath);
|
||||||
|
|
||||||
_directoryService.ClearAndDeleteDirectory(tempLocation);
|
DirectoryService.ClearAndDeleteDirectory(tempLocation);
|
||||||
(new FileInfo(zipPath)).Delete();
|
(new FileInfo(zipPath)).Delete();
|
||||||
|
|
||||||
return File(fileBytes, "application/zip", Path.GetFileName(zipPath));
|
return File(fileBytes, "application/zip", Path.GetFileName(zipPath));
|
||||||
|
@ -95,7 +95,7 @@ namespace API.Services
|
|||||||
/// Deletes all files within the directory, then the directory itself.
|
/// Deletes all files within the directory, then the directory itself.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="directoryPath"></param>
|
/// <param name="directoryPath"></param>
|
||||||
public void ClearAndDeleteDirectory(string directoryPath)
|
public static void ClearAndDeleteDirectory(string directoryPath)
|
||||||
{
|
{
|
||||||
DirectoryInfo di = new DirectoryInfo(directoryPath);
|
DirectoryInfo di = new DirectoryInfo(directoryPath);
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ namespace API.Services
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="directoryPath"></param>
|
/// <param name="directoryPath"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public void ClearDirectory(string directoryPath)
|
public static void ClearDirectory(string directoryPath)
|
||||||
{
|
{
|
||||||
var di = new DirectoryInfo(directoryPath);
|
var di = new DirectoryInfo(directoryPath);
|
||||||
if (!di.Exists) return;
|
if (!di.Exists) return;
|
||||||
|
@ -100,7 +100,7 @@ namespace API.Services
|
|||||||
public void CleanupTemp()
|
public void CleanupTemp()
|
||||||
{
|
{
|
||||||
var tempDirectory = Path.Join(Directory.GetCurrentDirectory(), "temp");
|
var tempDirectory = Path.Join(Directory.GetCurrentDirectory(), "temp");
|
||||||
BackgroundJob.Enqueue((() => _directoryService.ClearDirectory(tempDirectory)));
|
BackgroundJob.Enqueue((() => DirectoryService.ClearDirectory(tempDirectory)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BackupDatabase()
|
public void BackupDatabase()
|
||||||
|
@ -82,7 +82,7 @@ namespace API.Services.Tasks
|
|||||||
|
|
||||||
var tempDirectory = Path.Join(_tempDirectory, dateString);
|
var tempDirectory = Path.Join(_tempDirectory, dateString);
|
||||||
DirectoryService.ExistOrCreate(tempDirectory);
|
DirectoryService.ExistOrCreate(tempDirectory);
|
||||||
_directoryService.ClearDirectory(tempDirectory);
|
DirectoryService.ClearDirectory(tempDirectory);
|
||||||
|
|
||||||
_directoryService.CopyFilesToDirectory(
|
_directoryService.CopyFilesToDirectory(
|
||||||
_backupFiles.Select(file => Path.Join(Directory.GetCurrentDirectory(), file)).ToList(), tempDirectory);
|
_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");
|
_logger.LogError(ex, "There was an issue when archiving library backup");
|
||||||
}
|
}
|
||||||
|
|
||||||
_directoryService.ClearAndDeleteDirectory(tempDirectory);
|
DirectoryService.ClearAndDeleteDirectory(tempDirectory);
|
||||||
_logger.LogInformation("Database backup completed");
|
_logger.LogInformation("Database backup completed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ namespace API.Services.Tasks
|
|||||||
{
|
{
|
||||||
_logger.LogInformation("Cleaning temp directory");
|
_logger.LogInformation("Cleaning temp directory");
|
||||||
var tempDirectory = Path.Join(Directory.GetCurrentDirectory(), "temp");
|
var tempDirectory = Path.Join(Directory.GetCurrentDirectory(), "temp");
|
||||||
_directoryService.ClearDirectory(tempDirectory);
|
DirectoryService.ClearDirectory(tempDirectory);
|
||||||
_logger.LogInformation("Cleaning cache directory");
|
_logger.LogInformation("Cleaning cache directory");
|
||||||
_cacheService.Cleanup();
|
_cacheService.Cleanup();
|
||||||
_logger.LogInformation("Cleaning old database backups");
|
_logger.LogInformation("Cleaning old database backups");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user