Browse Source

When thumbnail update enforced, do not use any cached version

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
tobiasKaminsky 2 years ago
parent
commit
a981db2200

+ 16 - 4
app/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java

@@ -587,11 +587,17 @@ public final class ThumbnailsCacheManager {
             ServerFileInterface file = (ServerFileInterface) mFile;
             ServerFileInterface file = (ServerFileInterface) mFile;
             String imageKey = PREFIX_THUMBNAIL + file.getRemoteId();
             String imageKey = PREFIX_THUMBNAIL + file.getRemoteId();
 
 
-            // Check disk cache in background thread
-            thumbnail = getBitmapFromDiskCache(imageKey);
+            boolean updateEnforced = (file instanceof OCFile && ((OCFile) file).isUpdateThumbnailNeeded());
+
+            if (updateEnforced) {
+                thumbnail = null;
+            } else {
+                // Check disk cache in background thread
+                thumbnail = getBitmapFromDiskCache(imageKey);
+            }
 
 
             // Not found in disk cache
             // Not found in disk cache
-            if (thumbnail == null || (file instanceof OCFile && ((OCFile) file).isUpdateThumbnailNeeded())) {
+            if (thumbnail == null) {
                 int pxW;
                 int pxW;
                 int pxH;
                 int pxH;
                 pxW = pxH = getThumbnailDimension();
                 pxW = pxH = getThumbnailDimension();
@@ -624,7 +630,13 @@ public final class ThumbnailsCacheManager {
                 if (thumbnail == null) {
                 if (thumbnail == null) {
                     // check if resized version is available
                     // check if resized version is available
                     String resizedImageKey = PREFIX_RESIZED_IMAGE + file.getRemoteId();
                     String resizedImageKey = PREFIX_RESIZED_IMAGE + file.getRemoteId();
-                    Bitmap resizedImage = getBitmapFromDiskCache(resizedImageKey);
+
+                    Bitmap resizedImage;
+                    if (updateEnforced) {
+                        resizedImage = null;
+                    } else {
+                        resizedImage = getBitmapFromDiskCache(resizedImageKey);
+                    }
 
 
                     if (resizedImage != null) {
                     if (resizedImage != null) {
                         thumbnail = ThumbnailUtils.extractThumbnail(resizedImage, pxW, pxH);
                         thumbnail = ThumbnailUtils.extractThumbnail(resizedImage, pxW, pxH);