Răsfoiți Sursa

Merge pull request #3587 from nextcloud/deletedMediaFolders

Show only media folders that exist
Andy Scherzinger 6 ani în urmă
părinte
comite
55ddb391f0

+ 2 - 2
src/main/java/com/owncloud/android/datamodel/MediaProvider.java

@@ -118,8 +118,8 @@ public final class MediaProvider {
                         filePath = cursorImages.getString(cursorImages.getColumnIndexOrThrow(
                                 MediaStore.MediaColumns.DATA));
 
-                        // check if valid path
-                        if (filePath != null && filePath.lastIndexOf('/') > 0) {
+                        // check if valid path and file exists
+                        if (filePath != null && filePath.lastIndexOf('/') > 0 && new File(filePath).exists()) {
                             mediaFolder.filePaths.add(filePath);
                             mediaFolder.absolutePath = filePath.substring(0, filePath.lastIndexOf('/'));
                         }

+ 7 - 1
src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.java

@@ -226,7 +226,13 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
         Account currentAccount = AccountUtils.getCurrentOwnCloudAccount(this);
         for (SyncedFolder syncedFolder : syncedFolderArrayList) {
             if (currentAccount != null && syncedFolder.getAccount().equals(currentAccount.name)) {
-                currentAccountSyncedFoldersList.add(syncedFolder);
+
+                // delete non-existing & disabled synced folders
+                if (!new File(syncedFolder.getLocalPath()).exists() && !syncedFolder.isEnabled()) {
+                    mSyncedFolderProvider.deleteSyncedFolder(syncedFolder.getId());
+                } else {
+                    currentAccountSyncedFoldersList.add(syncedFolder);
+                }
             }
         }