Permalink
Browse files

[Frontend-GNOME] Refresh only modified favicons regardless cached one…

… being empty or not
  • Loading branch information...
1 parent b75e9b5 commit 757f04376e5b371d8873a5fbbf3bebbf17c27341 @meebey committed Mar 26, 2012
Showing with 19 additions and 20 deletions.
  1. +19 −20 src/Frontend-GNOME/Views/Chats/ProtocolChatView.cs
@@ -247,33 +247,32 @@ void DownloadServerIcon(string websiteUrl, FileInfo iconFile)
iconRequest.Proxy = proxy;
if (iconRequest is HttpWebRequest) {
var iconHttpRequest = (HttpWebRequest) iconRequest;
- if (iconFile.Exists && iconFile.Length > 0) {
+ if (iconFile.Exists) {
iconHttpRequest.IfModifiedSince = iconFile.LastWriteTime;
}
}
- using (var iconStream = iconFile.OpenWrite()) {
- WebResponse iconResponse;
- try {
- iconResponse = iconRequest.GetResponse();
- } catch (WebException ex) {
- if (ex.Response is HttpWebResponse) {
- var iconHttpResponse = (HttpWebResponse) ex.Response;
- if (iconHttpResponse.StatusCode == HttpStatusCode.NotModified) {
- // icon hasn't changed, nothing to do
- return;
- }
+ WebResponse iconResponse;
+ try {
+ iconResponse = iconRequest.GetResponse();
+ } catch (WebException ex) {
+ if (ex.Response is HttpWebResponse) {
+ var iconHttpResponse = (HttpWebResponse) ex.Response;
+ if (iconHttpResponse.StatusCode == HttpStatusCode.NotModified) {
+ // icon hasn't changed, nothing to do
+ return;
}
- throw;
}
+ throw;
+ }
- // save new or modified icon file
- using (var httpStream = iconResponse.GetResponseStream()) {
- byte[] buffer = new byte[4096];
- int read;
- while ((read = httpStream.Read(buffer, 0, buffer.Length)) > 0) {
- iconStream.Write(buffer, 0, read);
- }
+ // save new or modified icon file
+ using (var iconStream = iconFile.OpenWrite())
+ using (var httpStream = iconResponse.GetResponseStream()) {
+ byte[] buffer = new byte[4096];
+ int read;
+ while ((read = httpStream.Read(buffer, 0, buffer.Length)) > 0) {
+ iconStream.Write(buffer, 0, read);
}
}
}

0 comments on commit 757f043

Please sign in to comment.