From 531e26ea8b7d111c56adcbb7891af5811691e2a4 Mon Sep 17 00:00:00 2001 From: Matteo Salvi Date: Thu, 3 Oct 2024 00:15:58 +0200 Subject: [PATCH] refactoring(path): some fixes --- Library/AppConfig.Paths.pas | 9 ++------- Library/Icons.Base.pas | 6 +++--- Library/Kernel.Instance.pas | 23 +++++++++++++++++++---- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/Library/AppConfig.Paths.pas b/Library/AppConfig.Paths.pas index 1194e4e9..4e518fef 100644 --- a/Library/AppConfig.Paths.pas +++ b/Library/AppConfig.Paths.pas @@ -210,8 +210,8 @@ constructor TConfigPaths.Create(APathExecutable: string); strPathExe := APathExecutable; FSuitePathASuiteFolder := ExtractFilePath(strPathExe); - strFileListSql := ExtractFileNameOnly(strPathExe) + EXT_SQL; - strFileListXml := ExtractFileNameOnly(strPathExe) + EXT_XML; + strFileListSql := ExtractFileNameOnly(Application.ExeName) + EXT_SQL; + strFileListXml := ExtractFileNameOnly(Application.ExeName) + EXT_XML; {$IFDEF MSWINDOWS} FSuiteDrive := LowerCase(ExtractFileDrive(strPathExe)); @@ -235,11 +235,6 @@ constructor TConfigPaths.Create(APathExecutable: string); SysUtils.ForceDirectories(FSuitePathData); end; - //Check if xml list exists, else get sqlite list - FSuitePathList := FSuitePathData + strFileListXml; - if not FileExists(FSuitePathList) then - FSuitePathList := FSuitePathData + strFileListSql; - FSuitePathSettings := FSuitePathData + SETTINGS_FILENAME; //Path variables diff --git a/Library/Icons.Base.pas b/Library/Icons.Base.pas index 90367afe..096c9266 100644 --- a/Library/Icons.Base.pas +++ b/Library/Icons.Base.pas @@ -279,11 +279,11 @@ procedure TBaseIcon.ResetCacheIcon; strPathCacheIcon: String; begin strPathCacheIcon := PathCacheIcon; - TASuiteLogger.Debug('Reset cache icon %s', [PathCacheIcon]); + TASuiteLogger.Debug('Reset cache icon %s', [strPathCacheIcon]); //Small icon cache - if FileExists(PathCacheIcon) then - SysUtils.DeleteFile(PathCacheIcon); + if FileExists(strPathCacheIcon) then + SysUtils.DeleteFile(strPathCacheIcon); FCacheIconCRC := 0; end; diff --git a/Library/Kernel.Instance.pas b/Library/Kernel.Instance.pas index e1b6ccea..6f6bc3cb 100644 --- a/Library/Kernel.Instance.pas +++ b/Library/Kernel.Instance.pas @@ -71,7 +71,7 @@ TASuiteInstance = class implementation uses - Forms.ImportList, Kernel.Logger, Forms, Kernel.Consts, Utility.FileFolder, + Forms.ImportList, Kernel.Logger, Forms, Kernel.Consts, Utility.FileFolder, LazFileUtils, Utility.Misc, Utility.XML, VirtualTree.Methods, mormot.core.log, Kernel.Manager, mormot.core.base, VirtualTrees.Types; @@ -105,16 +105,31 @@ function TASuiteInstance.GetSmallHeightNode: Integer; constructor TASuiteInstance.Create; var I: Integer; + strFileListSql, strFileListXml: String; begin FScheduler := TScheduler.Create; FVSTEvents := TVirtualTreeEvents.Create; + //Create some classes + FPaths := TConfigPaths.Create(Application.ExeName); + //Params for I := 1 to ParamCount do HandleParam(ParamStr(I)); - //Create some classes - FPaths := TConfigPaths.Create(Application.ExeName); + strFileListSql := ExtractFileNameOnly(Application.ExeName) + EXT_SQL; + strFileListXml := ExtractFileNameOnly(Application.ExeName) + EXT_XML; + + // Check if FSuitePathList is a empty string + if (FPaths.SuitePathList = '') then + begin + //Check if xml list exists, else get sqlite list + FPaths.SuitePathList := FPaths.SuitePathData + strFileListXml; + if not FileExists(FPaths.SuitePathList) then + FPaths.SuitePathList := FPaths.SuitePathData + strFileListSql; + end + else + FPaths.SuitePathList := FPaths.RelativeToAbsolute(FPaths.SuitePathList); //Setup logger with TSynLog.Family do @@ -166,7 +181,7 @@ procedure TASuiteInstance.HandleParam(const Param: string; if sName <> '' then begin if (CompareText(sName, 'list') = 0) and (FirstInstance) then - FPaths.SuitePathList := FPaths.RelativeToAbsolute(RemoveAllQuotes(sValue)); + FPaths.SuitePathList := RemoveAllQuotes(sValue); //Add new node if (CompareText(sName, 'additem') = 0) and (Assigned(ASuiteManager.DBManager)) then