diff options
author | Jay Freeman (saurik) <saurik@saurik.com> | 2010-12-03 08:30:18 -0800 |
---|---|---|
committer | Jay Freeman (saurik) <saurik@saurik.com> | 2010-12-03 08:30:41 -0800 |
commit | 2f8563655132a23cd3e8b2da13135d7f8bac719c (patch) | |
tree | c2001d56f482c138fb2b93da5b6ab7a0a6b9a4eb /MobileCydia.mm | |
parent | 985d2dffd5fac3d86bf9f76ee972604e20c29f39 (diff) |
More correctly handle a couple (impossible) corner cases of the new Cytore import process.
Diffstat (limited to 'MobileCydia.mm')
-rw-r--r-- | MobileCydia.mm | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/MobileCydia.mm b/MobileCydia.mm index ba5118c..932b471 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -1491,7 +1491,7 @@ static void PackageImport(const void *key, const void *value, void *context) { NSDictionary *package((NSDictionary *) value); if (NSNumber *subscribed = [package objectForKey:@"IsSubscribed"]) - if ([subscribed boolValue]) + if ([subscribed boolValue] && !metadata->subscribed_) metadata->subscribed_ = true; if (NSDate *date = [package objectForKey:@"FirstSeen"]) { @@ -1500,22 +1500,12 @@ static void PackageImport(const void *key, const void *value, void *context) { metadata->first_ = time; } - bool versioned(false); + NSDate *date([package objectForKey:@"LastSeen"]); + NSString *version([package objectForKey:@"LastVersion"]); - if (NSDate *date = [package objectForKey:@"LastSeen"]) { + if (date != nil && version != nil) { time_t time([date timeIntervalSince1970]); - if (metadata->last_ < time || metadata->last_ == 0) { - metadata->last_ = time; - versioned = true; - } - } else if (metadata->last_ == 0) { - metadata->last_ = metadata->first_; - if (metadata->version_[0] == '\0') - versioned = true; - } - - if (versioned) - if (NSString *version = [package objectForKey:@"LastVersion"]) + if (metadata->last_ < time || metadata->last_ == 0) if (CFStringGetCString((CFStringRef) version, buffer, sizeof(buffer), kCFStringEncodingUTF8)) { size_t length(strlen(buffer)); uint16_t vhash(hashlittle(buffer, length)); @@ -1525,7 +1515,10 @@ static void PackageImport(const void *key, const void *value, void *context) { strncpy(metadata->version_, latest, sizeof(metadata->version_)); metadata->vhash_ = vhash; + + metadata->last_ = time; } + } } // }}} @@ -2265,15 +2258,12 @@ struct PackageNameOrdering : if (metadata->first_ == 0) metadata->first_ = now_; - if (metadata->last_ == 0) - metadata->last_ = metadata->first_; - if (metadata->vhash_ != vhash || strncmp(metadata->version_, latest, sizeof(metadata->version_)) != 0) { - if (metadata->version_[0] != '\0') - metadata->last_ = now_; strncpy(metadata->version_, latest, sizeof(metadata->version_)); metadata->vhash_ = vhash; - } + metadata->last_ = now_; + } else if (metadata->last_ == 0) + metadata->last_ = metadata->first_; _end _profile(Package$initWithVersion$Section) |