calvinaquino / LNReader-Android

Light novel reader for android test project collab
Apache License 2.0
120 stars 36 forks source link

Re-linking, possible url and referer handling in images table #254

Open yaminorito opened 7 years ago

yaminorito commented 7 years ago

1) After migrating an ancient db(very old and around 6 months not updated) from an old brick phone to a new tablet, big images won't load from storage(doesn't matter where it is saved), re-linking it would just fix the thumb images but not the big images. After fiddling with the pages.db and logcat, I've discovered that url and referer aren't properly updated. I can update the url and referer by opening each image through the app but that will just re-download the big image and overwrite the already existing image, not to mention doing that on more than 17000 images would be impossible.

my old db url: http://www.baka-tsuki.org..... or https://www.baka-tsuki.org..... referer: http://www.baka-tsuki.org..... or https://www.baka-tsuki.org.....

current BT header + domain name used by the app: url: https://baka-tsuki.org.... referer: https://baka-tsuki.org....

The stored images are properly linked to, but due to incorrect url and referer, the new stored image path isn't saved into the filepath. It may be needed to update those two columns during re-linking but that might need a "header" + "domainname" variable(that is updated regularly and is used by the app on most it's link functions) somewhere it would copy from whenever it re-links.

2) Very minor issue: The part of re-linking of big images is always at [1 of nnnnn], the counter doesn't seem to change though it does finish everything properly, that is, even before and after I fixed issue above by manually editing pages.db.

Nandaka commented 7 years ago

have you tried to change the referer/url using sql editor?

yaminorito commented 7 years ago

Yes that's what I did, it's working now. Though in the long run, it might be a good idea to optimize the filepath, url and referer handling since the three columns' values are almost the same most of the time. It would save some megabytes of storage, granted it won't break the app.

Nandaka commented 7 years ago

I think I can hardcode the referer (and maybe the file url, if hosted in bakatsuki) to always use current baka-tsuki url. https://github.com/calvinaquino/LNReader-Android/blob/master/app/src/main/java/com/erakk/lnreader/Constants.java#L9

for filepath, unless the user also moved the old images, I think I can remove it from db (so it always use the current path stored in config).

yaminorito commented 7 years ago

Removing it can be done later, maybe we can use a

try { test(); } catch (EpicFailException ex) { print(ex); oldmethod();

}

where test() ignores filepath and referer and use only url. This can probably be done through either image loading, re-linking, or image downloading. I haven't seen through the source code on those processes yet.