@@ -1604,18 +1604,6 @@ -(BOOL)updateArticle:(Article *)existingArticle ofFolder:(NSInteger)folderID wit
1604
1604
BOOL hasenclosure_flag = articleUpdate.hasEnclosure ;
1605
1605
NSString * articleEnclosure = articleUpdate.enclosure .vna_trimmed ;
1606
1606
1607
- // if a last update date is not provided, use either publication date or current date
1608
- if (!lastUpdate || [lastUpdate timeIntervalSince1970 ] == 0 ) {
1609
- lastUpdate = articleUpdate.publicationDate ;
1610
- if (!lastUpdate || [lastUpdate timeIntervalSince1970 ] == 0 ) {
1611
- lastUpdate = [NSDate date ];
1612
- }
1613
- articleUpdate.lastUpdate = lastUpdate;
1614
- }
1615
-
1616
- // Dates are stored as time intervals
1617
- NSTimeInterval lastUpdateIntervalSince1970 = lastUpdate.timeIntervalSince1970 ;
1618
-
1619
1607
// Set some defaults
1620
1608
if (userName == nil ) {
1621
1609
userName = @" " ;
@@ -1633,15 +1621,18 @@ -(BOOL)updateArticle:(Article *)existingArticle ofFolder:(NSInteger)folderID wit
1633
1621
if (!isArticleRevised) {
1634
1622
__block NSString * existingBody = existingArticle.body ;
1635
1623
__block NSString * existingEnclosure = existingArticle.enclosure ;
1624
+ __block NSDate * existingLastUpdate;
1636
1625
// the article text may not have been loaded yet, for instance if the folder is not displayed
1637
1626
if (existingBody == nil ) {
1638
1627
[queue inDatabase: ^(FMDatabase *db) {
1639
- FMResultSet * results = [db executeQuery: @" SELECT text, enclosure FROM messages WHERE folder_id=? AND message_id=?" ,
1628
+ FMResultSet * results = [db executeQuery: @" SELECT date, text, enclosure FROM messages WHERE folder_id=? AND message_id=?" ,
1640
1629
@(folderID), articleGuid];
1641
1630
if ([results next ]) {
1642
- existingBody = [results stringForColumnIndex: 0 ];
1643
- existingEnclosure = [results stringForColumnIndex: 1 ];
1644
- } else {
1631
+ existingLastUpdate = [NSDate dateWithTimeIntervalSince1970: [results stringForColumnIndex: 0 ].doubleValue];
1632
+ existingBody = [results stringForColumnIndex: 1 ];
1633
+ existingEnclosure = [results stringForColumnIndex: 2 ];
1634
+ } else { // should never occur; set sensible fallbacks anyway
1635
+ existingLastUpdate = articleUpdate.publicationDate ;
1645
1636
existingBody = @" " ;
1646
1637
existingEnclosure = @" " ;
1647
1638
}
@@ -1650,8 +1641,15 @@ -(BOOL)updateArticle:(Article *)existingArticle ofFolder:(NSInteger)folderID wit
1650
1641
}
1651
1642
isArticleRevised = ![existingBody isEqualToString: articleBody]
1652
1643
|| (articleEnclosure != nil && ![existingEnclosure isEqualToString: articleEnclosure]);
1644
+ // if a last update date is not provided in articleUpdate, use the one previously stored in database
1645
+ if (!lastUpdate || [lastUpdate timeIntervalSince1970 ] == 0 ) {
1646
+ lastUpdate = existingLastUpdate;
1647
+ }
1653
1648
}
1654
1649
1650
+ // Dates are stored as time intervals
1651
+ NSTimeInterval lastUpdateIntervalSince1970 = lastUpdate.timeIntervalSince1970 ;
1652
+
1655
1653
if (isArticleRevised) {
1656
1654
// Articles preexisting in database should be marked as revised.
1657
1655
// New articles created during the current refresh should not be marked as revised,
0 commit comments