metadata->first_ = time;
}
+ bool versioned(false);
+
if (NSDate *date = [package objectForKey:@"LastSeen"]) {
time_t time([date timeIntervalSince1970]);
if (metadata->last_ < time || metadata->last_ == 0) {
metadata->last_ = time;
- goto last;
+ versioned = true;
}
- } else if (metadata->last_ == 0) last: {
- NSString *version([package objectForKey:@"LastVersion"]);
- if (CFStringGetCString((CFStringRef) version, buffer, sizeof(buffer), kCFStringEncodingUTF8)) {
- size_t length(strlen(buffer));
- uint16_t vhash(hashlittle(buffer, length));
+ } else if (metadata->last_ == 0) {
+ metadata->last_ = metadata->first_;
+ if (metadata->version_[0] == '\0')
+ versioned = true;
+ }
- size_t capped(std::min<size_t>(8, length));
- char *latest(buffer + length - capped);
+ if (versioned)
+ if (NSString *version = [package objectForKey:@"LastVersion"])
+ if (CFStringGetCString((CFStringRef) version, buffer, sizeof(buffer), kCFStringEncodingUTF8)) {
+ size_t length(strlen(buffer));
+ uint16_t vhash(hashlittle(buffer, length));
- strncpy(metadata->version_, latest, sizeof(metadata->version_));
- metadata->vhash_ = vhash;
- }
- }
+ size_t capped(std::min<size_t>(8, length));
+ char *latest(buffer + length - capped);
+
+ strncpy(metadata->version_, latest, sizeof(metadata->version_));
+ metadata->vhash_ = vhash;
+ }
}
// }}}
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) {
- metadata->last_ = now_;
+ if (metadata->version_[0] != '\0')
+ metadata->last_ = now_;
strncpy(metadata->version_, latest, sizeof(metadata->version_));
metadata->vhash_ = vhash;
- } else if (metadata->last_ == 0)
- metadata->last_ = metadata->first_;
+ }
_end
_profile(Package$initWithVersion$Section)