summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ChangeLog1
-rwxr-xr-xbin/feed2imap2
-rw-r--r--lib/feed2imap/cache.rb15
3 files changed, 16 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index cdf8759..1137701 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
Feed2Imap 0.3 (date unknown)
============================
+* Fixed a problem with updated items being seen as updated at each update.
* Fixed a problem when the disconnection from the IMAP server failed.
reported by Ludovic Gomez <ludogomez@chez.com>
diff --git a/bin/feed2imap b/bin/feed2imap
index 06a6853..0095d9f 100755
--- a/bin/feed2imap
+++ b/bin/feed2imap
@@ -19,7 +19,7 @@ opts = OptionParser::new do |opts|
opts.on("-V", "--version", "Display Feed2Imap version") do |v|
version = true
end
- opts.on("-c", "--rebuild-cache", "Cache rebuilding run : will fetch everything and cache, as if it was already read.") do |c|
+ opts.on("-c", "--rebuild-cache", "Cache rebuilding run : will fetch everything and add to cache, without uploading to the IMAP server. Useful if your cache file was lost, and you don't want to re-read all the items.") do |c|
cacherebuild = true
end
opts.on("-f", "--config <file>", "Select alternate config file") do |f|
diff --git a/lib/feed2imap/cache.rb b/lib/feed2imap/cache.rb
index 48913f0..e270f05 100644
--- a/lib/feed2imap/cache.rb
+++ b/lib/feed2imap/cache.rb
@@ -113,6 +113,8 @@ class CachedChannel
# @nbnewitems is set by get_new_items, and is used to limit the number
# of (old) items serialized.
+ UPDATEDDEBUG = false
+
# Returns the really new items amongst items
def get_new_items(items)
# save number of new items
@@ -122,6 +124,13 @@ class CachedChannel
updateditems = []
@itemstemp = @items
items.each { |i| i.cacheditem ||= CachedItem::new(i) }
+ # debug : dump interesting info to stdout.
+ if UPDATEDDEBUG
+ puts "-------Items downloaded :----------"
+ items.each { |i| puts "#{i.cacheditem.to_s}" }
+ puts "-------Items already there :----------"
+ @items.each { |i| puts "#{i.to_s}" }
+ end
items.each do |i|
found = false
# Try to find a perfect match
@@ -146,7 +155,7 @@ class CachedChannel
found = true
# let's put j in front of itemstemp
@itemstemp.delete(j)
- @itemstemp.unshift(j)
+ @itemstemp.unshift(i.cacheditem)
break
end
end
@@ -197,4 +206,8 @@ class CachedItem
def create_index
@index = ItemCache.getindex
end
+
+ def to_s
+ "\"#{@title}\" #{@link} #{@hash}"
+ end
end