mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-07-09 03:04:19 -04:00
Shakeout Changes (#717)
* Make the appsettings public on Configuration and change how we detect when to migrate for non-docker users. * Fixed up non-docker copy command and removed duplicate check on source directory for a copy. * Don't delete files unless we know we are successful
This commit is contained in:
parent
8f00ecbf8c
commit
d143330e97
2
.gitignore
vendored
2
.gitignore
vendored
@ -507,6 +507,7 @@ UI/Web/dist/
|
|||||||
/API/config/backups/
|
/API/config/backups/
|
||||||
/API/config/cache/
|
/API/config/cache/
|
||||||
/API/config/temp/
|
/API/config/temp/
|
||||||
|
/API/config/stats/
|
||||||
/API/config/kavita.db
|
/API/config/kavita.db
|
||||||
/API/config/kavita.db-shm
|
/API/config/kavita.db-shm
|
||||||
/API/config/kavita.db-wal
|
/API/config/kavita.db-wal
|
||||||
@ -514,5 +515,6 @@ UI/Web/dist/
|
|||||||
/API/config/Hangfire-log.db
|
/API/config/Hangfire-log.db
|
||||||
API/config/covers/
|
API/config/covers/
|
||||||
API/config/*.db
|
API/config/*.db
|
||||||
|
API/config/stats/*
|
||||||
|
|
||||||
UI/Web/.vscode/settings.json
|
UI/Web/.vscode/settings.json
|
||||||
|
@ -44,14 +44,14 @@ namespace API.Data
|
|||||||
|
|
||||||
CopyAppFolders();
|
CopyAppFolders();
|
||||||
DeleteAppFolders();
|
DeleteAppFolders();
|
||||||
|
|
||||||
UpdateConfiguration();
|
UpdateConfiguration();
|
||||||
|
|
||||||
Console.WriteLine("Migration complete. All config files are now in config/ directory");
|
Console.WriteLine("Migration complete. All config files are now in config/ directory");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!new FileInfo(Path.Join(Directory.GetCurrentDirectory(), "appsettings.json")).Exists)
|
if (new FileInfo(Configuration.AppSettingsFilename).Exists)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Migration to config/ not needed");
|
Console.WriteLine("Migration to config/ not needed");
|
||||||
return;
|
return;
|
||||||
@ -63,12 +63,20 @@ namespace API.Data
|
|||||||
Console.WriteLine($"Creating {ConfigDirectory}");
|
Console.WriteLine($"Creating {ConfigDirectory}");
|
||||||
DirectoryService.ExistOrCreate(ConfigDirectory);
|
DirectoryService.ExistOrCreate(ConfigDirectory);
|
||||||
|
|
||||||
CopyLooseLeafFiles();
|
try
|
||||||
|
{
|
||||||
|
CopyLooseLeafFiles();
|
||||||
|
|
||||||
CopyAppFolders();
|
CopyAppFolders();
|
||||||
|
|
||||||
// Then we need to update the config file to point to the new DB file
|
// Then we need to update the config file to point to the new DB file
|
||||||
UpdateConfiguration();
|
UpdateConfiguration();
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
Console.WriteLine("There was an exception during migration. Please move everything manually.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Finally delete everything in the source directory
|
// Finally delete everything in the source directory
|
||||||
Console.WriteLine("Removing old files");
|
Console.WriteLine("Removing old files");
|
||||||
@ -99,13 +107,15 @@ namespace API.Data
|
|||||||
private static void CopyAppFolders()
|
private static void CopyAppFolders()
|
||||||
{
|
{
|
||||||
Console.WriteLine("Moving folders to config");
|
Console.WriteLine("Moving folders to config");
|
||||||
foreach (var folderToMove in AppFolders)
|
|
||||||
{
|
|
||||||
if (new DirectoryInfo(Path.Join(ConfigDirectory, folderToMove)).Exists) continue;
|
|
||||||
|
|
||||||
DirectoryService.CopyDirectoryToDirectory(Path.Join(Directory.GetCurrentDirectory(), folderToMove),
|
foreach (var folderToMove in AppFolders)
|
||||||
Path.Join(ConfigDirectory, folderToMove));
|
{
|
||||||
}
|
if (new DirectoryInfo(Path.Join(ConfigDirectory, folderToMove)).Exists) continue;
|
||||||
|
|
||||||
|
DirectoryService.CopyDirectoryToDirectory(Path.Join(Directory.GetCurrentDirectory(), folderToMove),
|
||||||
|
Path.Join(ConfigDirectory, folderToMove));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Console.WriteLine("Moving folders to config...DONE");
|
Console.WriteLine("Moving folders to config...DONE");
|
||||||
}
|
}
|
||||||
|
@ -136,13 +136,10 @@ namespace API.Services
|
|||||||
/// <param name="searchPattern">Defaults to *, meaning all files</param>
|
/// <param name="searchPattern">Defaults to *, meaning all files</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <exception cref="DirectoryNotFoundException"></exception>
|
/// <exception cref="DirectoryNotFoundException"></exception>
|
||||||
public static bool CopyDirectoryToDirectory(string sourceDirName, string destDirName, string searchPattern = "*")
|
public static bool CopyDirectoryToDirectory(string sourceDirName, string destDirName, string searchPattern = "")
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(sourceDirName)) return false;
|
if (string.IsNullOrEmpty(sourceDirName)) return false;
|
||||||
|
|
||||||
var di = new DirectoryInfo(sourceDirName);
|
|
||||||
if (!di.Exists) return false;
|
|
||||||
|
|
||||||
// Get the subdirectories for the specified directory.
|
// Get the subdirectories for the specified directory.
|
||||||
var dir = new DirectoryInfo(sourceDirName);
|
var dir = new DirectoryInfo(sourceDirName);
|
||||||
|
|
||||||
@ -156,7 +153,7 @@ namespace API.Services
|
|||||||
var dirs = dir.GetDirectories();
|
var dirs = dir.GetDirectories();
|
||||||
|
|
||||||
// If the destination directory doesn't exist, create it.
|
// If the destination directory doesn't exist, create it.
|
||||||
Directory.CreateDirectory(destDirName);
|
ExistOrCreate(destDirName);
|
||||||
|
|
||||||
// Get the files in the directory and copy them to the new location.
|
// Get the files in the directory and copy them to the new location.
|
||||||
var files = GetFilesWithExtension(dir.FullName, searchPattern).Select(n => new FileInfo(n));
|
var files = GetFilesWithExtension(dir.FullName, searchPattern).Select(n => new FileInfo(n));
|
||||||
|
@ -8,7 +8,7 @@ namespace Kavita.Common
|
|||||||
{
|
{
|
||||||
public static class Configuration
|
public static class Configuration
|
||||||
{
|
{
|
||||||
private static readonly string AppSettingsFilename = Path.Join("config", GetAppSettingFilename());
|
public static readonly string AppSettingsFilename = Path.Join("config", GetAppSettingFilename());
|
||||||
|
|
||||||
public static string Branch
|
public static string Branch
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user