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,30 +727,40 @@ 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);
for i:=0 to LinkCnt-1 do begin if FileVersion<=1 then begin
APath:=XMLPath+'IncludeLinks/Link'+IntToStr(i)+'/'; LinkCnt:=XMLConfig.GetValue(XMLPath+'IncludeLinks/Count',0);
if not CfgStrToDate(XMLConfig.GetValue(APath+'LastTimeUsed/Value', for i:=0 to LinkCnt-1 do begin
CurrDateStr),LastTimeUsed) APath:=XMLPath+'IncludeLinks/Link'+IntToStr(i)+'/';
then if not CfgStrToDate(XMLConfig.GetValue(APath+'LastTimeUsed/Value',
LastTimeUsed:=CurrDate; CurrDateStr),LastTimeUsed)
then begin
debugln(['TCodeCache.LoadIncludeLinksFromXML invalid date: ',XMLConfig.GetValue(APath+'LastTimeUsed/Value','')]);
LastTimeUsed:=CurrDate;
end;
// ToDo: check if link has expired
// ToDo: check if link has expired IncludeFilename:=XMLConfig.GetValue(APath+'IncludeFilename/Value','');
//debugln(['TCodeCache.LoadIncludeLinksFromXML CurrDate=',DateToStr(CurrDate),' xml=',XMLConfig.GetValue(APath+'LastTimeUsed/Value',''),' Days=',CurrDate-LastTimeUsed,' ',IncludeFilename]);
IncludeFilename:=XMLConfig.GetValue(APath+'IncludeFilename/Value',''); if IncludeFilename='' then continue;
if IncludeFilename='' then continue; IncludedByFile:=XMLConfig.GetValue(APath+'IncludedByFilename/Value','');
IncludedByFile:=XMLConfig.GetValue(APath+'IncludedByFilename/Value',''); if (FExpirationTimeInDays<=0)
NewLink:=TIncludedByLink.Create(IncludeFilename,IncludedByFile, or (CurrDate-LastTimeUsed<=FExpirationTimeInDays) then begin
LastTimeUsed); NewLink:=TIncludedByLink.Create(IncludeFilename,IncludedByFile,
FIncludeLinks.Add(NewLink); LastTimeUsed);
FIncludeLinks.Add(NewLink);
end;
end;
end; end;
Result:=true; Result:=true;
except except