Browse Source

bug fix

git-svn-id: https://svn.kenai.com/svn/winsw~subversion/trunk@32 c8b2a3fe-9b5b-6a51-a37e-dc31b0e308fa
kohsuke 17 years ago
parent
commit
07d017ed3e
1 changed files with 5 additions and 3 deletions
  1. 5 3
      Main.cs

+ 5 - 3
Main.cs

@@ -414,7 +414,8 @@ namespace winsw
             FileStream tmpstream = new FileStream(To+".tmp", FileMode.Create);
             CopyStream(rsp.GetResponseStream(), tmpstream);
             // only after we successfully downloaded a file, overwrite the existing one
-            File.Delete(To);
+            if(File.Exists(To))
+                File.Delete(To);
             File.Move(To + ".tmp", To);
         }
 
@@ -424,7 +425,7 @@ namespace winsw
             while (true)
             {
                 int len = i.Read(buf, 0, buf.Length);
-                if (len <= 0) return;
+                if (len <= 0) break;
                 o.Write(buf, 0, len);
             }
             i.Close();
@@ -617,7 +618,8 @@ namespace winsw
                 }
                 catch (Exception e)
                 {
-                    WriteEvent("Failed to download " + d.From, e);
+                    LogEvent("Failed to download " + d.From + " to " + d.To + "\n" + e.Message);
+                    WriteEvent("Failed to download " + d.From +" to "+d.To, e);
                     // but just keep going
                 }
             }