From f26c90b114a5fdb3b701cd7e73ce9328a93eaeda Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Thu, 2 Jul 2015 07:47:43 -0700 Subject: Do not lock the dpkg status database (this is OK). --- MobileCydia.mm | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'MobileCydia.mm') diff --git a/MobileCydia.mm b/MobileCydia.mm index f39543e..612cd23 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -1103,6 +1103,7 @@ typedef std::map< unsigned long, _H > SourceMap; CYPool pool_; unsigned era_; + _H delock_; pkgCacheFile cache_; pkgDepCache::Policy *policy_; @@ -1507,6 +1508,10 @@ static void PackageImport(const void *key, const void *value, void *context) { } // }}} +static NSDate *GetStatusDate() { + return [[[NSFileManager defaultManager] attributesOfItemAtPath:@"/var/lib/dpkg/status" error:NULL] fileModificationDate]; +} + static void SaveConfig(NSObject *lock) { @synchronized (lock) { _trace(); @@ -3830,7 +3835,7 @@ class CydiaLogCleaner : } _end - _root(_system->Lock()); + delock_ = GetStatusDate(); _trace(); OpProgress progress; @@ -3867,7 +3872,6 @@ class CydiaLogCleaner : } } - _system->UnLock(); return; } _trace(); @@ -4096,7 +4100,13 @@ class CydiaLogCleaner : if (substrate) RestartSubstrate_ = true; - _system->UnLock(); + if (![delock_ isEqual:GetStatusDate()]) { + [delegate_ addProgressEventOnMainThread:[CydiaProgressEvent eventWithMessage:UCLocalize("DPKG_LOCKED") ofType:kCydiaProgressEventTypeError] forTask:title]; + return; + } + + delock_ = nil; + pkgPackageManager::OrderResult result(manager_->DoInstall(statusfd_)); if ([self popErrorWithTitle:title]) return; @@ -4123,6 +4133,10 @@ class CydiaLogCleaner : [self update]; } +- (bool) delocked { + return ![delock_ isEqual:GetStatusDate()]; +} + - (bool) upgrade { NSString *title(UCLocalize("UPGRADE")); if ([self popErrorWithTitle:title forOperation:pkgDistUpgrade(cache_)]) @@ -9688,6 +9702,9 @@ _end [appcache_ reloadURLWithCache:YES]; } } + + if ([database_ delocked]) + [self reloadData]; } - (void) setConfigurationData:(NSString *)data { -- cgit v1.2.3