codetools: do not load old include links

git-svn-id: trunk@25681 -
This commit is contained in:
mattias 2010-05-27 08:02:59 +00:00
parent 71d77a25cd
commit e05038a12d

View File

@ -41,6 +41,8 @@ uses
Classes, SysUtils, SourceLog, LinkScanner, FileProcs, Classes, SysUtils, SourceLog, LinkScanner, FileProcs,
Avl_Tree, Laz_XMLCfg; Avl_Tree, Laz_XMLCfg;
const
IncludeLinksFileVersion = 1;
type type
TCodeCache = class; TCodeCache = class;
@ -706,6 +708,7 @@ begin
CurTime:=Now; CurTime:=Now;
ExpirationTime:=TDateTime(FExpirationTimeInDays); ExpirationTime:=TDateTime(FExpirationTimeInDays);
UpdateIncludeLinks; UpdateIncludeLinks;
XMLConfig.SetValue(XMLPath+'IncludeLinks/Version',IncludeLinksFileVersion);
XMLConfig.SetDeleteValue(XMLPath+'IncludeLinks/ExpirationTimeInDays', XMLConfig.SetDeleteValue(XMLPath+'IncludeLinks/ExpirationTimeInDays',
FExpirationTimeInDays,0); FExpirationTimeInDays,0);
Index:=0; Index:=0;
@ -724,31 +727,41 @@ var LinkCnt, i: integer;
IncludeFilename, IncludedByFile, APath: string; IncludeFilename, IncludedByFile, APath: string;
NewLink: TIncludedByLink; NewLink: TIncludedByLink;
CurrDateStr: String; CurrDateStr: String;
FileVersion: longint;
begin begin
try try
FIncludeLinks.FreeAndClear; FIncludeLinks.FreeAndClear;
FileVersion:=XMLConfig.GetValue(XMLPath+'IncludeLinks/Version',0);
FExpirationTimeInDays:=XMLConfig.GetValue( FExpirationTimeInDays:=XMLConfig.GetValue(
XMLPath+'IncludeLinks/ExpirationTimeInDays', XMLPath+'IncludeLinks/ExpirationTimeInDays',
FExpirationTimeInDays); FExpirationTimeInDays);
LinkCnt:=XMLConfig.GetValue(XMLPath+'IncludeLinks/Count',0); //debugln(['TCodeCache.LoadIncludeLinksFromXML FExpirationTimeInDays=',FExpirationTimeInDays]);
CurrDate:=Date; CurrDate:=Date;
CurrDateStr:=DateToStr(CurrDate); CurrDateStr:=DateToCfgStr(CurrDate);
if FileVersion<=1 then begin
LinkCnt:=XMLConfig.GetValue(XMLPath+'IncludeLinks/Count',0);
for i:=0 to LinkCnt-1 do begin for i:=0 to LinkCnt-1 do begin
APath:=XMLPath+'IncludeLinks/Link'+IntToStr(i)+'/'; APath:=XMLPath+'IncludeLinks/Link'+IntToStr(i)+'/';
if not CfgStrToDate(XMLConfig.GetValue(APath+'LastTimeUsed/Value', if not CfgStrToDate(XMLConfig.GetValue(APath+'LastTimeUsed/Value',
CurrDateStr),LastTimeUsed) CurrDateStr),LastTimeUsed)
then then begin
debugln(['TCodeCache.LoadIncludeLinksFromXML invalid date: ',XMLConfig.GetValue(APath+'LastTimeUsed/Value','')]);
LastTimeUsed:=CurrDate; LastTimeUsed:=CurrDate;
end;
// ToDo: check if link has expired // ToDo: check if link has expired
IncludeFilename:=XMLConfig.GetValue(APath+'IncludeFilename/Value',''); IncludeFilename:=XMLConfig.GetValue(APath+'IncludeFilename/Value','');
//debugln(['TCodeCache.LoadIncludeLinksFromXML CurrDate=',DateToStr(CurrDate),' xml=',XMLConfig.GetValue(APath+'LastTimeUsed/Value',''),' Days=',CurrDate-LastTimeUsed,' ',IncludeFilename]);
if IncludeFilename='' then continue; if IncludeFilename='' then continue;
IncludedByFile:=XMLConfig.GetValue(APath+'IncludedByFilename/Value',''); IncludedByFile:=XMLConfig.GetValue(APath+'IncludedByFilename/Value','');
if (FExpirationTimeInDays<=0)
or (CurrDate-LastTimeUsed<=FExpirationTimeInDays) then begin
NewLink:=TIncludedByLink.Create(IncludeFilename,IncludedByFile, NewLink:=TIncludedByLink.Create(IncludeFilename,IncludedByFile,
LastTimeUsed); LastTimeUsed);
FIncludeLinks.Add(NewLink); FIncludeLinks.Add(NewLink);
end; end;
end;
end;
Result:=true; Result:=true;
except except
Result:=false; Result:=false;