For 1.2 RC3 I modified the update check so that it first retrieves the last modified date of the project feed (HTTP HEAD method), if the date is newer than the last check than it will download the feed. This should reduce the amount of traffic on our website. [skip ci]

This commit is contained in:
RKrom 2014-11-14 10:45:45 +01:00
parent 380f581bbe
commit c6d6431a81
5 changed files with 51 additions and 2 deletions

View file

@ -60,6 +60,10 @@ namespace Greenshot.Experimental {
return false;
}
LOG.DebugFormat("Update check is due, last check was {0} check needs to be made after {1} (which is one {2} later)", conf.LastUpdateCheck, checkTime, conf.UpdateCheckInterval);
if (!SourceForgeHelper.isRSSModifiedAfter(conf.LastUpdateCheck)) {
LOG.DebugFormat("RSS feed has not been updated since after {0}", conf.LastUpdateCheck);
return false;
}
}
}
return true;

View file

@ -7,6 +7,16 @@ CHANGE LOG:
@DETAILVERSION@
Features:
Changes:
Bugs Resolved:
1.2.2.43-380f581 RC2
Features:
* Added the possibility to select the region to capture by using the keyboard, use the cursor keys to move the cursor (ctrl-key speeds up the movement) and the enter key to mark the start and ending.
* FEATURE-757: Greenshot will now store the last used region in the greenshot.ini, which makes it also available after a restart.

View file

@ -410,8 +410,12 @@ namespace GreenshotPlugin.Core {
// CheckForUnstable = true;
if (string.IsNullOrEmpty(LastSaveWithVersion)) {
// Store version, this can be used later to fix settings after an update
LastSaveWithVersion = Assembly.GetEntryAssembly().GetName().Version.ToString();
try {
// Store version, this can be used later to fix settings after an update
LastSaveWithVersion = Assembly.GetEntryAssembly().GetName().Version.ToString();
} catch {
}
// Disable the AutoReduceColors as it causes issues with Mozzila applications and some others
OutputFileAutoReduceColors = false;
}

View file

@ -336,6 +336,27 @@ namespace GreenshotPlugin.Core {
return responseData;
}
/// <summary>
/// Get LastModified for a URI
/// </summary>
/// <param name="uri">Uri</param>
/// <returns>DateTime</returns>
public static DateTime GetLastModified(Uri uri) {
HttpWebRequest webRequest;
try {
webRequest = (HttpWebRequest)NetworkHelper.CreateWebRequest(uri);
webRequest.Method = "HEAD";
HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();
LOG.DebugFormat("RSS feed was updated at {0}", webResponse.LastModified);
return webResponse.LastModified;
} catch (Exception wE) {
LOG.WarnFormat("Problem requesting HTTP - HEAD on uri {0}", uri);
LOG.Warn(wE.Message);
// Pretend it is old
return DateTime.MinValue;
}
}
}
/// <summary>

View file

@ -98,6 +98,16 @@ namespace GreenshotPlugin.Core {
private static ILog LOG = LogManager.GetLogger(typeof(SourceForgeHelper));
private const String RSSFEED = "http://getgreenshot.org/project-feed/";
/// <summary>
/// This is using the HTTP HEAD Method to check if the RSS Feed is modified after the supplied date
/// </summary>
/// <param name="updateTime">DateTime</param>
/// <returns>true if the feed is newer</returns>
public static bool isRSSModifiedAfter(DateTime updateTime) {
DateTime lastModified = NetworkHelper.GetLastModified(new Uri(RSSFEED));
return updateTime.CompareTo(lastModified) < 0;
}
/// <summary>
/// Read the Greenshot RSS feed, so we can use this information to check for updates
/// </summary>