]> git.notmuchmail.org Git - sup/commitdiff
sup-sync-back bugfixes
authorwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Mon, 28 May 2007 02:55:32 +0000 (02:55 +0000)
committerwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Mon, 28 May 2007 02:55:32 +0000 (02:55 +0000)
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@419 5c8cc53c-5e98-4d25-b20a-d8db53a31250

bin/sup-sync-back

index 608a1ea467c67149448dac06db02bdd799df067d..46977e08531fff78eb8866d7408c391b9d92f256 100644 (file)
@@ -57,6 +57,7 @@ unless opts[:dry_run]
   spam_fp = File.open(opts[:move_spam], "a") if opts[:move_spam]
 end
 
+any_modified = false
 begin
   sources.each { |s| s.reset! }
   
@@ -100,22 +101,24 @@ begin
       nil # don't actually add anything!
     end
     $stderr.puts "Scanned #{num_scanned}, deleted #{num_deleted}, moved #{num_moved} messages from #{source}."
+    any_modified = true if num_deleted > 0 || num_moved > 0
     out_fp.close unless opts[:dry_run]
 
     unless opts[:dry_run]
-      deleted_fp.flush
-      spam_fp.flush
+      deleted_fp.flush if deleted_fp
+      spam_fp.flush if spam_fp
       out_fp.close
       FileUtils.mv out_fp.path, URI(source.uri).path
     end
   end
 
   unless opts[:dry_run]
-    deleted_fp.close
-    spam_fp.close
+    deleted_fp.close if deleted_fp
+    spam_fp.close if spam_fp
   end
 
-  $stderr.puts "Done. You should run sup-sync --changed #{sources.join(' ')}"
+  $stderr.puts "Done."
+  $stderr.puts "You should run sup-sync --changed #{sources.join(' ')}." if any_modified
 rescue Exception => e
   File.open("sup-exception-log.txt", "w") { |f| f.puts e.backtrace }
   raise