From c4e74094779d0b0b231bb0a38dc4b8bd608792d9 Mon Sep 17 00:00:00 2001 From: lnu Date: Wed, 3 Oct 2007 18:59:31 +0000 Subject: updated version ; write new cache to temp file then rename git-svn-id: svn+ssh://svn.gna.org/svn/feed2imap/trunk/feed2imap@133 f70e237a-67f3-0310-a06c-d2b8a7116972 --- lib/feed2imap/feed2imap.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'lib/feed2imap/feed2imap.rb') diff --git a/lib/feed2imap/feed2imap.rb b/lib/feed2imap/feed2imap.rb index 061e8c6..08ceb4f 100644 --- a/lib/feed2imap/feed2imap.rb +++ b/lib/feed2imap/feed2imap.rb @@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA =end # Feed2Imap version -F2I_VERSION = '0.9' +F2I_VERSION = '0.9.2' require 'feed2imap/config' require 'feed2imap/cache' @@ -244,9 +244,14 @@ class Feed2Imap end @logger.info("Finished. Saving cache ...") begin - File::open(@config.cache, 'w') { |f| @cache.save(f) } + File::open("#{@config.cache}.new", 'w') { |f| @cache.save(f) } rescue - @logger.fatal("Exception caught while writing cache to #{@config.cache}: #{$!}") + @logger.fatal("Exception caught while writing new cache to #{@config.cache}.new: #{$!}") + end + begin + File::rename("#{@config.cache}.new", @config.cache) + rescue + @logger.fatal("Exception caught while renaming #{@config.cache}.new to #{@config.cache}: #{$!}") end @logger.info("Closing IMAP connections ...") @config.imap_accounts.each_value do |ac| -- cgit v1.2.3-54-g00ecf