From 7bfd2c432df5ac3d7ec22c54c4ba405e22983af5 Mon Sep 17 00:00:00 2001 From: Joseph Milazzo Date: Wed, 3 Nov 2021 09:07:04 -0500 Subject: [PATCH] Feature/docker parity (#714) * Refactored all the config files for Kavita to be loaded from config/. This will allow docker to just mount one folder and for Update functionality to be trivial. * Cleaned up documentation around new update method. * Updated docker files to support config directory * Removed entrypoint, no longer needed * Update appsettings to point to config directory for logs * Updated message for docker users that are upgrading * Ensure that docker users that have not updated their mount points from upgrade cannot start the server * Code smells * More cleanup * Added entrypoint to fix bind mount issues * Updated README with new folder structure * Fixed build system for new setup * Updated string path if user is docker * Updated the migration flow for docker to work properly and Fixed LogFile configuration updating. * Migrating docker images is now working 100% * Fixed config from bad code * Code cleanup * Fixed monorepo-build.sh Co-authored-by: Chris Plaatjes --- API/Services/DirectoryService.cs | 22 +++++++--------------- monorepo-build.sh | 12 ++++++------ 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/API/Services/DirectoryService.cs b/API/Services/DirectoryService.cs index a606b774c..1148c60bb 100644 --- a/API/Services/DirectoryService.cs +++ b/API/Services/DirectoryService.cs @@ -48,6 +48,7 @@ namespace API.Services reSearchPattern.IsMatch(Path.GetExtension(file)) && !Path.GetFileName(file).StartsWith(Parser.Parser.MacOsMetadataFileStartsWith)); } + /// /// Returns a list of folders from end of fullPath to rootPath. If a file is passed at the end of the fullPath, it will be ignored. /// @@ -96,7 +97,7 @@ namespace API.Services return di.Exists; } - public static IEnumerable GetFiles(string path, string searchPatternExpression = "", + public IEnumerable GetFiles(string path, string searchPatternExpression = "", SearchOption searchOption = SearchOption.TopDirectoryOnly) { if (searchPatternExpression != string.Empty) @@ -132,10 +133,10 @@ namespace API.Services /// /// /// - /// Defaults to empty string, meaning all files + /// Defaults to *, meaning all files /// /// - public static bool CopyDirectoryToDirectory(string sourceDirName, string destDirName, string searchPattern = "") + public bool CopyDirectoryToDirectory(string sourceDirName, string destDirName, string searchPattern = "*") { if (string.IsNullOrEmpty(sourceDirName)) return false; @@ -177,13 +178,7 @@ namespace API.Services - /// - /// Get files with a file extension - /// - /// - /// Regex to use for searching on regex. Defaults to empty string for all files - /// - public static string[] GetFilesWithExtension(string path, string searchPatternExpression = "") + public string[] GetFilesWithExtension(string path, string searchPatternExpression = "") { if (searchPatternExpression != string.Empty) { @@ -381,11 +376,8 @@ namespace API.Services IEnumerable subDirs; string[] files; - try - { - // Default EnumerationOptions will ignore system and hidden folders - subDirs = Directory.GetDirectories(currentDir, "*", new EnumerationOptions()) - .Where(path => ExcludeDirectories.Matches(path).Count == 0); + try { + subDirs = Directory.GetDirectories(currentDir).Where(path => ExcludeDirectories.Matches(path).Count == 0); } // Thrown if we do not have discovery permission on the directory. catch (UnauthorizedAccessException e) { diff --git a/monorepo-build.sh b/monorepo-build.sh index be452b235..6d3cf85d8 100755 --- a/monorepo-build.sh +++ b/monorepo-build.sh @@ -50,22 +50,22 @@ Package() echo "Copying Install information" cp ../INSTALL.txt "$lOutputFolder"/README.txt - + echo "Copying LICENSE" cp ../LICENSE "$lOutputFolder"/LICENSE.txt echo "Show API structure" find - + echo "Copying appsettings.json" - cp appsettings.Development.json $lOutputFolder/appsettings.json + cp appsettings.Development.json $lOutputFolder/config/appsettings.json echo "Creating tar" cd ../$outputFolder/"$runtime"/ tar -czvf ../kavita-$runtime.tar.gz Kavita - - ProgressEnd "Creating $runtime Package for $framework" - + + ProgressEnd "Creating $runtime Package for $framework" + } dir=$PWD