wallabag / android-app

Android application to read your articles saved in your wallabag. You can also easily add new articles.
https://www.wallabag.org
GNU General Public License v3.0
471 stars 259 forks source link

Re-download images #453

Open ngosang opened 7 years ago

ngosang commented 7 years ago

wallabag-app master branch

I have the option "Cache images locally" checked in the app (not in wallabag web). Sometimes there is a problem downloading the images and I can't see it in some articles. Related https://github.com/wallabag/android-app/issues/444#issuecomment-283505478 If I delete the article and add it again usually works, so there is no problem with the article.

I propose to implement 3 solutions: 1) When you update the article list try to re-download missing images (I mean partial, I don't know if full update tries to redownload all images but I think this is to much overhead) 2) If you enter in one article and images are not stored locally, try to show the online version, and then save them locally. 3) Add a button to refetch the article (download both, text and images).

screenshot_2017-03-05-15-41-56

Strubbl commented 7 years ago

When you update the article list try to re-download missing images (I mean partial, I don't know if full update tries to redownload all images but I think this is to much overhead)

i should already have this behaviour. it looks for the image being in the file system and if not tries to download it. @di72nn how about the status of the image being downloaded on any http error? Does it mark as "image cached"? What if only one image out of three of one article is fetched and the others are not. What is the status in the db?

If you enter in one article and images are not stored locally, try to show the online version, and then save them locally.

should also be the current behaviour as in the app. it is implemented like this except for the part to save them locally if the online version is available (only for article display, on feed update it fetches online images). see https://github.com/wallabag/android-app/blob/master/app/src/main/java/fr/gaulupeau/apps/Poche/network/ImageCacheUtils.java#L50

Add a button to refetch the article (download both, text and images).

good idea, i would like to have that, too.

di72nn commented 7 years ago

Here's how the image cache currently works:

Current implementation is not perfect, but it is good to have this feature anyway.

Sometimes there is a problem downloading the images and I can't see it in some articles. If I delete the article and add it again usually works, so there is no problem with the article.

This is theoretically possible (if the download is interrupted, the partially downloaded image won't be removed or re-downloaded in the future; this should be fixed, BTW), but if the image was inaccessible at the moment of the "image fetching", the online version is used.

When you update the article list try to re-download missing images (I mean partial, I don't know if full update tries to redownload all images but I think this is to much overhead)

As I said, currently the unit of caching is article: either we have its content cached or not. Not the separate images. We need to introduce more advanced caching in order to implement it. That would be a good feature, but it is not a priority for me.

If you enter in one article and images are not stored locally, try to show the online version, and then save them locally.

In such cases the online version is shown, but not cached.

Add a button to refetch the article (download both, text and images).

I'm ok for a button to refetch article images (basically, set the "images downloaded" flag to false and run the "image fetching" operation), but not the content (the content is never changed locally, use fast update to get server-side changes).

ngosang commented 7 years ago

Regardless of the result (all of the images downloaded / some of the images downloaded / none of the images downloaded) the "images downloaded" flag for the article is set true.

Could you change that? if any image download fails set it to false so next time will be retried. This could be problematic in some cases but...

If you enter in one article and images are not stored locally, try to show the online version, and then save them locally. In such cases the online version is shown, but not cached.

Could you test that? I can't replicate the issue now but I think this is not the current behaviour. Take a look at the first comment screenshot, that images exists but wasn't displayed. I deleted the article and added it again and everything worked.

di72nn commented 7 years ago

Could you change that? if any image download fails set it to false so next time will be retried. This could be problematic in some cases but...

I just realized I've never thought about errors related to connection (flaky connection, etc.; I've thought only about server-side issues). That should be done for the client-side errors.

Could you test that? I can't replicate the issue now but I think this is not the current behaviour. Take a look at the first comment screenshot, that images exists but wasn't displayed. I deleted the article and added it again and everything worked.

I don't know how to test it. Next time you encounter anything like that, we at least need logs of opening the article for reading (it should contain some info regarding URL replacements).

ngosang commented 7 years ago

I did a small change to skip HTTP 500 errors in my build. Maybe it helps you in some way.

---
 app/src/main/java/fr/gaulupeau/apps/Poche/service/MainService.java | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/app/src/main/java/fr/gaulupeau/apps/Poche/service/MainService.java b/app/src/main/java/fr/gaulupeau/apps/Poche/service/MainService.java
index 5ade058..f38eba8 100644
--- a/app/src/main/java/fr/gaulupeau/apps/Poche/service/MainService.java
+++ b/app/src/main/java/fr/gaulupeau/apps/Poche/service/MainService.java
@@ -275,6 +275,12 @@ public class MainService extends IntentServiceBase {
                 itemResult = null;
             }

+            if(itemResult != null && !itemResult.isSuccess()
+                    && itemResult.getErrorType() == ActionResult.ErrorType.UNKNOWN) {
+                Log.i(TAG, "syncOfflineQueue() ignoring UNKNOWN");
+                itemResult = null;
+            }
+
             if(itemResult == null || itemResult.isSuccess()) {
                 completedQueueItems.add(item);
             } else if(itemResult.getErrorType() != null) {
-- 
Radexw commented 6 years ago

Hi guys, I just subscribed to your project on codeTriage. This is my first time when I join an open-source project :D so please be patient with me . I read your comments here regarding fetching the images. What do you say about downloading files via Android's download manager? In this way you have the status for downloaded files and also a broadcast to know when file was downloaded successfully.

di72nn commented 6 years ago

Hi @Radexw I can't say whether using download manager is an acceptable solution right now. Anyway, it is of somewhat low priority, since it mostly works and there are other things that are not implemented at all.