mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-07-09 03:04:19 -04:00
Fixed an issue where docker users were not properly backing up the database. Removed an empty File for when covers/ had nothing in it. (#692)
This commit is contained in:
parent
9d84bfca5f
commit
6fb01eefa4
@ -71,10 +71,10 @@ namespace API.Controllers
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("backup-db")]
|
||||
public ActionResult BackupDatabase()
|
||||
public async Task<ActionResult> BackupDatabase()
|
||||
{
|
||||
_logger.LogInformation("{UserName} is backing up database of server from admin dashboard", User.GetUsername());
|
||||
_backupService.BackupDatabase();
|
||||
await _backupService.BackupDatabase();
|
||||
|
||||
return Ok();
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ using API.Extensions;
|
||||
using API.Interfaces;
|
||||
using API.Interfaces.Services;
|
||||
using Hangfire;
|
||||
using Kavita.Common.EnvironmentInfo;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
@ -33,6 +34,21 @@ namespace API.Services.Tasks
|
||||
var maxRollingFiles = config.GetMaxRollingFiles();
|
||||
var loggingSection = config.GetLoggingFileName();
|
||||
var files = LogFiles(maxRollingFiles, loggingSection);
|
||||
|
||||
if (new OsInfo(Array.Empty<IOsVersionAdapter>()).IsDocker)
|
||||
{
|
||||
_backupFiles = new List<string>()
|
||||
{
|
||||
"data/appsettings.json",
|
||||
"data/Hangfire.db",
|
||||
"data/Hangfire-log.db",
|
||||
"data/kavita.db",
|
||||
"data/kavita.db-shm", // This wont always be there
|
||||
"data/kavita.db-wal" // This wont always be there
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
_backupFiles = new List<string>()
|
||||
{
|
||||
"appsettings.json",
|
||||
@ -40,8 +56,10 @@ namespace API.Services.Tasks
|
||||
"Hangfire-log.db",
|
||||
"kavita.db",
|
||||
"kavita.db-shm", // This wont always be there
|
||||
"kavita.db-wal", // This wont always be there
|
||||
"kavita.db-wal" // This wont always be there
|
||||
};
|
||||
}
|
||||
|
||||
foreach (var file in files.Select(f => (new FileInfo(f)).Name).ToList())
|
||||
{
|
||||
_backupFiles.Add(file);
|
||||
@ -129,6 +147,11 @@ namespace API.Services.Tasks
|
||||
{
|
||||
// Swallow exception. This can be a duplicate cover being copied as chapter and volumes can share same file.
|
||||
}
|
||||
|
||||
if (!_directoryService.GetFiles(outputTempDir).Any())
|
||||
{
|
||||
DirectoryService.ClearAndDeleteDirectory(outputTempDir);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -41,6 +41,7 @@ namespace Kavita.Common.EnvironmentInfo
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public OsInfo(IEnumerable<IOsVersionAdapter> versionAdapters)
|
||||
|
Loading…
x
Reference in New Issue
Block a user