瀏覽代碼

do not let media scanner throw an exception as otherwise upload fails

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
tobiasKaminsky 4 年之前
父節點
當前提交
9049b51de0
共有 1 個文件被更改,包括 6 次插入1 次删除
  1. 6 1
      src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java

+ 6 - 1
src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java

@@ -1767,7 +1767,12 @@ public class FileDataStorageManager {
                 values.put(MediaStore.Images.Media.DATE_ADDED, System.currentTimeMillis() / 1000);
                 values.put(MediaStore.Images.Media.RELATIVE_PATH, path);
                 values.put(MediaStore.Images.Media.IS_PENDING, 0);
-                contentResolver.insert(MediaStore.Images.Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY), values);
+                try {
+                    contentResolver.insert(MediaStore.Images.Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY),
+                                           values);
+                } catch (IllegalArgumentException e) {
+                    Log_OC.e("MediaScanner", "Adding image to media scanner failed: " + e);
+                }
             } else {
                 Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
                 intent.setData(Uri.fromFile(new File(path)));