Skip to content

Commit

Permalink
refactoring(path): some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
salvadorbs committed Oct 6, 2024
1 parent 2543334 commit 531e26e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
9 changes: 2 additions & 7 deletions Library/AppConfig.Paths.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions Library/Icons.Base.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
23 changes: 19 additions & 4 deletions Library/Kernel.Instance.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 531e26e

Please sign in to comment.