mirror of
https://github.com/nextcloud/android.git
synced 2024-11-23 13:45:35 +03:00
Clean up DB upgrade
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
582f29b041
commit
de962ad8b6
2 changed files with 9 additions and 4 deletions
|
@ -30,7 +30,6 @@ public class MediaFolder {
|
|||
public static final Integer CUSTOM = 0;
|
||||
public static final Integer IMAGE = 1;
|
||||
public static final Integer VIDEO = 2;
|
||||
public static final Integer LEGACY = 3;
|
||||
|
||||
/** name of the folder. */
|
||||
public String folderName;
|
||||
|
|
|
@ -988,11 +988,16 @@ public class FileContentProvider extends ContentProvider {
|
|||
Log_OC.i(SQL, "Entering in the #20 ADD in onUpgrade");
|
||||
db.beginTransaction();
|
||||
try {
|
||||
// add type column default being LEGACY (3)
|
||||
// add type column default being CUSTOM (0)
|
||||
db.execSQL(ALTER_TABLE + ProviderTableMeta.SYNCED_FOLDERS_TABLE_NAME +
|
||||
ADD_COLUMN + ProviderTableMeta.SYNCED_FOLDER_TYPE +
|
||||
" INTEGER " + " DEFAULT 3");
|
||||
" INTEGER " + " DEFAULT 0");
|
||||
|
||||
// create arbitrary data table
|
||||
createArbitraryData(db);
|
||||
|
||||
// magic to split out existing synced folders in two when needed
|
||||
// otherwise, we migrate them to their proper type (image or video)
|
||||
ContentResolver contentResolver = getContext().getContentResolver();
|
||||
|
||||
SyncedFolderProvider syncedFolderProvider = new SyncedFolderProvider(contentResolver);
|
||||
|
@ -1001,7 +1006,8 @@ public class FileContentProvider extends ContentProvider {
|
|||
final List<MediaFolder> videoMediaFolders = MediaProvider.getVideoFolders(contentResolver, 0);
|
||||
|
||||
ArrayList<Long> idsToDelete = new ArrayList<>();
|
||||
for (SyncedFolder syncedFolder : syncedFolderProvider.getSyncedFolders()) {
|
||||
List<SyncedFolder> syncedFolders = syncedFolderProvider.getSyncedFolders();
|
||||
for (SyncedFolder syncedFolder : syncedFolders) {
|
||||
idsToDelete.add(syncedFolder.getId());
|
||||
for (int i = 0; i < imageMediaFolders.size(); i++) {
|
||||
if (imageMediaFolders.get(i).absolutePath.equals(syncedFolder.getLocalPath())) {
|
||||
|
|
Loading…
Reference in a new issue