paulrehkugler / xkcd

xkcd iPhone app
MIT License
44 stars 9 forks source link

Download all / Delete all crash in iOS 6 #21

Closed leberwurstsaft closed 11 years ago

leberwurstsaft commented 11 years ago

2012-10-12 20:43:52.239 xkcd[8113:907] Store path: /var/mobile/Applications/9EFA3B99-3422-4C64-B24B-BDA58C8ED53B/Documents/comics.sqlite 2012-10-12 20:43:52.823 xkcd[8113:907] Scroll error 2012-10-12 20:43:52.864 xkcd[8113:907] Starting synchronization of downloaded images 2012-10-12 20:43:52.869 xkcd[8113:907] Synchronized downloaded images: 0 images 2012-10-12 20:44:59.956 xkcd[8113:907] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'keypath downloaded not found in entity ' * First throw call stack: (0x37b782a3 0x35e8897f 0x39487597 0x394872bd 0x39486ed5 0x3948664f 0x39486119 0x39485531 0x39483e2b 0x35039 0x3a447 0x33121 0x30f61 0x3d101 0x3900ab01 0x38e5eabb 0x38ed38d7 0x357c5bd9 0x368684b7 0x3686d1bd 0x37b4bf3b 0x37abeebd 0x37abed49 0x37ffb2eb 0x38e9d301 0x2d101 0x3c5a9b20) libc++abi.dylib: terminate called throwing an exception

josharian commented 11 years ago

Thanks! Should be a simple fix. Will look into this asap, probably this weekend...

leberwurstsaft commented 11 years ago

I just tried to add a downloaded field to the CD model, then let it create a new .sqlite by skipping copying the comics.sqlite and reimporting the date into the new .sqlite. That certainly fixed the crash, but somehow I must be missing some detail regarding the unique primary index. My go at fixing that unique index resulted in the download stopping after 5 images ;)

Also, the downloaded attribute will probably have to be set to yes at some point after the successful download. Just saying.

zackhariton commented 11 years ago

I was looking at this as well. Queries in Comic.m (request.predicate = [NSPredicate predicateWithFormat:kAttributeDownloaded @" = %@", @YES];) search using the downloaded property which doesn't exist after this commit. https://github.com/josharian/xkcd/commit/324e94daad976e986ace3c3f7e885fcdabd0c73d

Hope that makes things a little easier.

josharian commented 11 years ago

Thanks for looking into this! Here's a bit more info, in case you decide to keep looking at this.

Keeping a downloaded attribute in the CD model ended up being a pain. (1) Restores, iCloud, etc. made it necessary to do extra work to keep it synced with the reality on the filesystem. (2) Removing it made the CD model more or less uniform across all devices, which kept updates simple. (This will change when we add starring favorites, tracking read/unread state, etc., but in the short term, it's a nice simplifier.)

Because of that, I switched to simply maintaining an NSSet of download comics in memory, which gets reloaded directly from the filesystem and gets updated as necessary. See e.g. +synchronizeDownloadedImages in https://github.com/josharian/xkcd/blob/master/Classes/Comic.m. I simply failed to remove the old references to CD. So the fix here should be as simple as using downloadedImages instead of CD when deleting all.

josharian commented 11 years ago

Also affects download all. (Sigh.)