]> git.saurik.com Git - uikittools.git/commitdiff
Unregister totally obsolete applications.
authorJay Freeman (saurik) <saurik@saurik.com>
Wed, 6 Feb 2013 10:29:39 +0000 (10:29 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Wed, 6 Feb 2013 10:53:29 +0000 (10:53 +0000)
uicache.mm

index aac264da1025db822b6383beba69354681a5bb7a..29694d66f6a8ab28a208a5010410f2ddbf68c6f2 100644 (file)
     [self addObject:info];
 }
 
+- (NSArray *) allInfoDictionaries {
+    return self;
+}
+
 @end
 
 @interface NSMutableDictionary (Cydia)
     [self setObject:info forKey:bundle];
 }
 
+- (NSArray *) allInfoDictionaries {
+    return [self allValues];
+}
+
 @end
 
 int main(int argc, const char *argv[]) {
@@ -116,6 +124,11 @@ int main(int argc, const char *argv[]) {
 
         NSArray *cached([cache objectForKey:@"InfoPlistCachedKeys"]);
 
+        NSMutableSet *removed([NSMutableSet set]);
+        for (NSDictionary *info in [before allInfoDictionaries])
+            if (NSString *path = [info objectForKey:@"Path"])
+                [removed addObject:path];
+
         if (NSArray *apps = [manager contentsOfDirectoryAtPath:@"/Applications" error:&error]) {
             for (NSString *app in apps)
                 if ([app hasSuffix:@".app"]) {
@@ -125,6 +138,7 @@ int main(int argc, const char *argv[]) {
                     if (NSMutableDictionary *info = [NSMutableDictionary dictionaryWithContentsOfFile:plist]) {
                         if (NSString *identifier = [info objectForKey:@"CFBundleIdentifier"]) {
                             [bundles setObject:path forKey:identifier];
+                            [removed removeObject:path];
 
                             if (cached != nil) {
                                 NSMutableDictionary *merged([before objectForKey:identifier]);
@@ -168,6 +182,9 @@ int main(int argc, const char *argv[]) {
                 NSString *path([bundles objectForKey:identifier]);
                 [workspace registerApplication:[NSURL fileURLWithPath:path]];
             }
+
+            for (NSString *path in removed)
+                [workspace unregisterApplication:[NSURL fileURLWithPath:path]];
         }
     } else fprintf(stderr, "cannot open cache file. incorrect user?\n");
   cached: