@@ -1601,6 +1601,8 @@ -(BOOL)updateArticle:(Article *)existingArticle ofFolder:(NSInteger)folderID wit
1601
1601
NSString * articleGuid = articleUpdate.guid ;
1602
1602
NSInteger parentId = articleUpdate.parentId ;
1603
1603
BOOL revised_flag = articleUpdate.isRevised ;
1604
+ BOOL hasenclosure_flag = articleUpdate.hasEnclosure ;
1605
+ NSString * articleEnclosure = articleUpdate.enclosure .vna_trimmed ;
1604
1606
1605
1607
// if a last update date is not provided, use either publication date or current date
1606
1608
if (!lastUpdate || [lastUpdate timeIntervalSince1970 ] == 0 ) {
@@ -1624,26 +1626,30 @@ -(BOOL)updateArticle:(Article *)existingArticle ofFolder:(NSInteger)folderID wit
1624
1626
articleTitle = [NSString vna_stringByRemovingHTML: articleBody].vna_firstNonBlankLine ;
1625
1627
}
1626
1628
1627
- // The article is revised if either the title or the body has changed.
1629
+ // The article is revised if either the title, the body or the enclosure link has changed.
1628
1630
1629
1631
NSString * existingTitle = existingArticle.title ;
1630
1632
BOOL isArticleRevised = ![existingTitle isEqualToString: articleTitle];
1631
1633
if (!isArticleRevised) {
1632
- __block NSString * existingBody = existingArticle.body ;
1634
+ __block NSString * existingBody;
1635
+ __block NSString * existingEnclosure;
1633
1636
// the article text may not have been loaded yet, for instance if the folder is not displayed
1634
1637
if (existingBody == nil ) {
1635
1638
[queue inDatabase: ^(FMDatabase *db) {
1636
- FMResultSet * results = [db executeQuery: @" SELECT text FROM messages WHERE folder_id=? AND message_id=?" ,
1639
+ FMResultSet * results = [db executeQuery: @" SELECT text, enclosure FROM messages WHERE folder_id=? AND message_id=?" ,
1637
1640
@(folderID), articleGuid];
1638
1641
if ([results next ]) {
1639
- existingBody = [results stringForColumn: @" text" ];
1642
+ existingBody = [results stringForColumnIndex: 0 ];
1643
+ existingEnclosure = [results stringForColumnIndex: 1 ];
1640
1644
} else {
1641
1645
existingBody = @" " ;
1646
+ existingEnclosure = @" " ;
1642
1647
}
1643
1648
[results close ];
1644
1649
}];
1645
1650
}
1646
- isArticleRevised = ![existingBody isEqualToString: articleBody];
1651
+ isArticleRevised = ![existingBody isEqualToString: articleBody]
1652
+ || ![existingEnclosure isEqualToString: articleEnclosure];
1647
1653
}
1648
1654
1649
1655
if (isArticleRevised) {
@@ -1657,15 +1663,18 @@ -(BOOL)updateArticle:(Article *)existingArticle ofFolder:(NSInteger)folderID wit
1657
1663
// Note: we never change the publication date
1658
1664
__block BOOL success;
1659
1665
[queue inDatabase: ^(FMDatabase *db) {
1660
- success = [db executeUpdate: @" UPDATE messages SET parent_id=?, sender=?, link=?, date=?, "
1661
- @" read_flag=0, title=?, text=?, revised_flag=? WHERE folder_id=? AND message_id=?" ,
1666
+ success = [db executeUpdate: @" UPDATE messages SET parent_id=?, sender=?, link=?, date=? "
1667
+ @" read_flag=0, title=?, text=?, revised_flag=?, enclosure=?, hasenclosure_flag=? "
1668
+ @" WHERE folder_id=? AND message_id=?" ,
1662
1669
@(parentId),
1663
1670
userName,
1664
1671
articleLink,
1665
1672
@(lastUpdateIntervalSince1970),
1666
1673
articleTitle,
1667
1674
articleBody,
1668
1675
@(revised_flag),
1676
+ articleEnclosure,
1677
+ @(hasenclosure_flag),
1669
1678
@(folderID),
1670
1679
articleGuid];
1671
1680
0 commit comments