mirror of
https://github.com/textmate/textmate.git
synced 2026-04-28 03:00:34 -04:00
Make bundle update frequency configurable
This is introduced only for testing.
This commit is contained in:
@@ -18,10 +18,11 @@ OAK_DEBUG_VAR(BundlesManager_FSEvents);
|
||||
|
||||
NSString* const kUserDefaultsDisableBundleUpdatesKey = @"disableBundleUpdates";
|
||||
NSString* const kUserDefaultsLastBundleUpdateCheckKey = @"lastBundleUpdateCheck";
|
||||
NSString* const kUserDefaultsBundleUpdateFrequencyKey = @"bundleUpdateFrequency";
|
||||
NSString* const BundlesManagerBundlesDidChangeNotification = @"BundlesManagerBundlesDidChangeNotification";
|
||||
|
||||
static std::string const kInstallDirectory = NULL_STR;
|
||||
static double const kPollInterval = 3*60*60;
|
||||
static NSTimeInterval const kDefaultPollInterval = 3*60*60;
|
||||
|
||||
@interface BundlesManager ()
|
||||
{
|
||||
@@ -52,6 +53,11 @@ static double const kPollInterval = 3*60*60;
|
||||
return instance;
|
||||
}
|
||||
|
||||
- (NSTimeInterval)updateFrequency
|
||||
{
|
||||
return [[NSUserDefaults standardUserDefaults] floatForKey:kUserDefaultsBundleUpdateFrequencyKey] ?: kDefaultPollInterval;
|
||||
}
|
||||
|
||||
- (id)init
|
||||
{
|
||||
if(self = [super init])
|
||||
@@ -88,7 +94,7 @@ static double const kPollInterval = 3*60*60;
|
||||
return;
|
||||
|
||||
NSDate* lastCheck = [[NSUserDefaults standardUserDefaults] objectForKey:kUserDefaultsLastBundleUpdateCheckKey] ?: [NSDate distantPast];
|
||||
NSDate* nextCheck = [lastCheck dateByAddingTimeInterval:kPollInterval];
|
||||
NSDate* nextCheck = [lastCheck dateByAddingTimeInterval:self.updateFrequency];
|
||||
NSTimeInterval checkAfterSeconds = std::max<NSTimeInterval>(1, [nextCheck timeIntervalSinceNow]);
|
||||
D(DBF_BundlesManager, bug("perform next check in %.1f hours\n", checkAfterSeconds/60/60););
|
||||
self.updateTimer = [NSTimer scheduledTimerWithTimeInterval:checkAfterSeconds target:self selector:@selector(didFireUpdateTimer:) userInfo:nil repeats:NO];
|
||||
@@ -160,7 +166,7 @@ static double const kPollInterval = 3*60*60;
|
||||
else
|
||||
{
|
||||
self.activityText = @"Error updating bundles, will retry later.";
|
||||
lastCheck = [lastCheck dateByAddingTimeInterval:-(kPollInterval - 30*60)]; // retry in 30 minutes
|
||||
lastCheck = [lastCheck dateByAddingTimeInterval:30*60-self.updateFrequency]; // retry in 30 minutes
|
||||
|
||||
for(auto source : failedSources)
|
||||
fprintf(stderr, "*** error downloading ‘%s’\n", source->url().c_str());
|
||||
|
||||
Reference in New Issue
Block a user