33using System . Collections . Generic ;
44using System . ComponentModel ;
55using System . Diagnostics ;
6+ using System . Globalization ;
67using System . IO ;
78using System . Linq ;
89using System . Net ;
@@ -26,6 +27,7 @@ public static class UpdateManager
2627 } ;
2728 public static string PathPrefix = LauncherKitUpdateUrls . First ( ) ;
2829 public static string AppDataPath = Environment . ExpandEnvironmentVariables ( @"%appdata%\Spore ModAPI Launcher" ) ;
30+ public static string UpdaterDateTimePath = Path . Combine ( AppDataPath , "updateDateTime.info" ) ;
2931 public static string UpdateInfoDestPath = Path . Combine ( AppDataPath , "update.info" ) ;
3032 public static string UpdaterDestPath = Path . Combine ( AppDataPath , "updater.exe" ) ;
3133 public static string UpdaterBlockPath = Path . Combine ( AppDataPath , "noUpdateCheck.info" ) ;
@@ -113,6 +115,26 @@ public static void CheckForUpdates()
113115 if ( File . Exists ( UpdaterDestPath ) )
114116 File . Delete ( UpdaterDestPath ) ;
115117
118+ if ( File . Exists ( UpdaterDateTimePath ) )
119+ {
120+ try
121+ {
122+ string lastUpdateDateTimeString = File . ReadAllText ( UpdaterDateTimePath ) ;
123+ DateTime lastUpdateDateTime = DateTime . ParseExact ( lastUpdateDateTimeString ,
124+ "yyyy-MM-dd HH:mm" ,
125+ CultureInfo . InvariantCulture ) ;
126+
127+ if ( ( DateTime . Now - lastUpdateDateTime ) . TotalHours < 1 )
128+ {
129+ return ;
130+ }
131+ }
132+ catch ( Exception )
133+ {
134+ File . Delete ( UpdaterDateTimePath ) ;
135+ }
136+ }
137+
116138 if ( ! File . Exists ( UpdaterBlockPath ) && HasInternetConnection ( ) )
117139 {
118140 try
@@ -261,6 +283,8 @@ public static void CheckForUpdates()
261283 dialog . ShowDialog ( ) ;
262284 }
263285 }
286+
287+ File . WriteAllText ( UpdaterDateTimePath , DateTime . Now . ToString ( "yyyy-MM-dd HH:mm" ) ) ;
264288 }
265289 catch ( Exception ex )
266290 {
0 commit comments