Save 'LastDate' attribute to cache files
This commit is contained in:
parent
21ad59927f
commit
5cc00b8df3
|
@ -27,6 +27,10 @@ AtomFeed::Parse ( Config* cfg )
|
||||||
|
|
||||||
RootParse( cfg, xfeed );
|
RootParse( cfg, xfeed );
|
||||||
ParseEntries( cfg, xfeed );
|
ParseEntries( cfg, xfeed );
|
||||||
|
|
||||||
|
time_t tt_lastDate = lastDate.Time_t();
|
||||||
|
BFile* cacheFile = new BFile( filePath, B_READ_WRITE );
|
||||||
|
cacheFile->WriteAttr( "LastDate", B_TIME_TYPE, 0, &tt_lastDate, sizeof(time_t) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -76,6 +80,9 @@ AtomFeed::EntryParse ( Config* cfg, tinyxml2::XMLElement* xentry )
|
||||||
set = newEntry->SetDate( xentry->FirstChildElement("updated") );
|
set = newEntry->SetDate( xentry->FirstChildElement("updated") );
|
||||||
if ( !set ) set = newEntry->SetDate( xentry->FirstChildElement("published") );
|
if ( !set ) set = newEntry->SetDate( xentry->FirstChildElement("published") );
|
||||||
|
|
||||||
|
if ( lastDate != NULL || lastDate < newEntry->date )
|
||||||
|
lastDate = newEntry->date;
|
||||||
|
|
||||||
if ( xcontent ) {
|
if ( xcontent ) {
|
||||||
xcontent->Accept( &xprinter );
|
xcontent->Accept( &xprinter );
|
||||||
newEntry->SetContent( xprinter.CStr() );
|
newEntry->SetContent( xprinter.CStr() );
|
||||||
|
|
|
@ -14,7 +14,8 @@ Feed::Feed ( BString path, Config* cfg )
|
||||||
filePath = GetCachePath( path, cfg );
|
filePath = GetCachePath( path, cfg );
|
||||||
}
|
}
|
||||||
|
|
||||||
Feed::Feed ( ) {
|
Feed::Feed ( )
|
||||||
|
{
|
||||||
title = BString("");
|
title = BString("");
|
||||||
description = BString("");
|
description = BString("");
|
||||||
homeUrl = BString("");
|
homeUrl = BString("");
|
||||||
|
@ -52,7 +53,7 @@ Feed::FetchRemoteFeed ( BString givenPath, Config* cfg )
|
||||||
filename.Append(splitName);
|
filename.Append(splitName);
|
||||||
BFile* cacheFile = new BFile( filename, B_READ_WRITE | B_CREATE_FILE );
|
BFile* cacheFile = new BFile( filename, B_READ_WRITE | B_CREATE_FILE );
|
||||||
|
|
||||||
cacheFile->ReadAttr( "FeedSum", B_STRING_TYPE, 0,
|
cacheFile->ReadAttr( "LastHash", B_STRING_TYPE, 0,
|
||||||
oldHash, 41 );
|
oldHash, 41 );
|
||||||
|
|
||||||
if ( cfg->verbose )
|
if ( cfg->verbose )
|
||||||
|
@ -60,7 +61,7 @@ Feed::FetchRemoteFeed ( BString givenPath, Config* cfg )
|
||||||
|
|
||||||
webFetch( givenUrl, cacheFile, newHash );
|
webFetch( givenUrl, cacheFile, newHash );
|
||||||
|
|
||||||
cacheFile->WriteAttr( "FeedSum", B_STRING_TYPE, 0,
|
cacheFile->WriteAttr( "LastHash", B_STRING_TYPE, 0,
|
||||||
newHash->String(), newHash->CountChars() );
|
newHash->String(), newHash->CountChars() );
|
||||||
|
|
||||||
if ( *(newHash) == BString(oldHash) )
|
if ( *(newHash) == BString(oldHash) )
|
||||||
|
|
|
@ -27,6 +27,10 @@ RssFeed::Parse ( Config* cfg )
|
||||||
|
|
||||||
RootParse( cfg, xchan );
|
RootParse( cfg, xchan );
|
||||||
ParseEntries( cfg, xchan );
|
ParseEntries( cfg, xchan );
|
||||||
|
|
||||||
|
time_t tt_lastDate = lastDate.Time_t();
|
||||||
|
BFile* cacheFile = new BFile( filePath, B_READ_WRITE );
|
||||||
|
cacheFile->WriteAttr( "LastDate", B_TIME_TYPE, 0, &tt_lastDate, sizeof(time_t) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------
|
// -------------------------------------
|
||||||
|
@ -58,6 +62,9 @@ RssFeed::EntryParse ( Config* cfg, tinyxml2::XMLElement* xitem )
|
||||||
if (cfg->verbose )
|
if (cfg->verbose )
|
||||||
printf("\t%s\n", newEntry->title.String());
|
printf("\t%s\n", newEntry->title.String());
|
||||||
|
|
||||||
|
if ( lastDate == NULL || lastDate < newEntry->date )
|
||||||
|
lastDate = newEntry->date;
|
||||||
|
|
||||||
if ( withinDateRange( cfg->minDate, newEntry->date, cfg->maxDate ) )
|
if ( withinDateRange( cfg->minDate, newEntry->date, cfg->maxDate ) )
|
||||||
entries.AddItem( newEntry );
|
entries.AddItem( newEntry );
|
||||||
}
|
}
|
||||||
|
|
Ŝarĝante…
Reference in New Issue