summaryrefslogtreecommitdiff
path: root/MobileCydia.mm
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2015-07-02 07:47:43 -0700
committerJay Freeman (saurik) <saurik@saurik.com>2015-07-02 07:47:43 -0700
commitf26c90b114a5fdb3b701cd7e73ce9328a93eaeda (patch)
treeb1f8ab76d3ccdca9da9a0ceb88986bfa2d8e1f70 /MobileCydia.mm
parent4e47935026ff175a7b1db931ac6263a2f34fd0fa (diff)
Do not lock the dpkg status database (this is OK).
Diffstat (limited to 'MobileCydia.mm')
-rw-r--r--MobileCydia.mm23
1 files changed, 20 insertions, 3 deletions
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<Source> > SourceMap;
CYPool pool_;
unsigned era_;
+ _H<NSDate> 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 {