[blam] ItemStore: Save(): Close the writer so it flushes.



commit 8e549215cbbc39a4b5192835426a64006b7d6d9c
Author: Carlos Martín Nieto <carlos cmartin tk>
Date:   Sun Oct 10 14:57:20 2010 +0100

    ItemStore: Save(): Close the writer so it flushes.
    
    Otherwise, it may do a short write and we won't be able to read
    the data back in.

 src/ItemStore.cs |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/src/ItemStore.cs b/src/ItemStore.cs
index 2980c6f..234ff48 100644
--- a/src/ItemStore.cs
+++ b/src/ItemStore.cs
@@ -54,9 +54,9 @@ namespace Imendio.Blam
             XmlReader reader;
             try{
                 reader = new XmlTextReader(itemfile);
-            } catch(FileNotFoundException){
+            } catch(Exception e){
+                Console.WriteLine(e.Message);
                 Console.WriteLine("item file not found");
-                instance.items = new Hashtable();
                 return;
             }
 
@@ -80,8 +80,9 @@ namespace Imendio.Blam
             Item[] items = new Item[instance.items.Count];
             instance.items.Values.CopyTo(items, 0);
             SyndicationFeed sf = new SyndicationFeed(items);
-            SyndicationFeedFormatter fmtr = new Atom10FeedFormatter(sf);
+            Atom10FeedFormatter fmtr = sf.GetAtom10Formatter();
             fmtr.WriteTo(writer);
+            writer.Close();
         }
 
        private ItemStore ()



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]