From e9620394c198caa00f96b1ad92255af0688f723a Mon Sep 17 00:00:00 2001 From: alperozturk Date: Mon, 23 Sep 2024 14:50:39 +0200 Subject: [PATCH] Rebase, Add Migration84to85 Signed-off-by: alperozturk --- .../client/database/NextcloudDatabase.kt | 2 + .../database/migrations/Migration84to85.kt | 47 +++++++++++++++++++ .../fileNameValidator/FileNameValidator.kt | 2 +- .../ui/dialog/CreateFolderDialogFragment.kt | 3 +- 4 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 app/src/main/java/com/nextcloud/client/database/migrations/Migration84to85.kt diff --git a/app/src/main/java/com/nextcloud/client/database/NextcloudDatabase.kt b/app/src/main/java/com/nextcloud/client/database/NextcloudDatabase.kt index 4af5536e0f17..ad20792694f3 100644 --- a/app/src/main/java/com/nextcloud/client/database/NextcloudDatabase.kt +++ b/app/src/main/java/com/nextcloud/client/database/NextcloudDatabase.kt @@ -29,6 +29,7 @@ import com.nextcloud.client.database.entity.SyncedFolderEntity import com.nextcloud.client.database.entity.UploadEntity import com.nextcloud.client.database.entity.VirtualEntity import com.nextcloud.client.database.migrations.DatabaseMigrationUtil +import com.nextcloud.client.database.migrations.Migration84to85 import com.nextcloud.client.database.migrations.Migration67to68 import com.nextcloud.client.database.migrations.RoomMigration import com.nextcloud.client.database.migrations.addLegacyMigrations @@ -101,6 +102,7 @@ abstract class NextcloudDatabase : RoomDatabase() { .addLegacyMigrations(clock, context) .addMigrations(RoomMigration()) .addMigrations(Migration67to68()) + .addMigrations(Migration84to85) .fallbackToDestructiveMigration() .build() } diff --git a/app/src/main/java/com/nextcloud/client/database/migrations/Migration84to85.kt b/app/src/main/java/com/nextcloud/client/database/migrations/Migration84to85.kt new file mode 100644 index 000000000000..88302eabf653 --- /dev/null +++ b/app/src/main/java/com/nextcloud/client/database/migrations/Migration84to85.kt @@ -0,0 +1,47 @@ +/* + * Nextcloud - Android Client + * + * SPDX-FileCopyrightText: 2024 Alper Ozturk + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +package com.nextcloud.client.database.migrations + +import androidx.room.migration.Migration +import androidx.sqlite.db.SupportSQLiteDatabase +import com.owncloud.android.db.ProviderMeta + +@Suppress("MagicNumber", "NestedBlockDepth") +val Migration84to85 = object : Migration(84, 85) { + override fun migrate(db: SupportSQLiteDatabase) { + db.run { + execSQL( + """ + CREATE TABLE IF NOT EXISTS `offline_operations_new` ( + `_id` INTEGER PRIMARY KEY AUTOINCREMENT, + `offline_operations_parent_oc_file_id` INTEGER, + `offline_operations_path` TEXT, + `offline_operations_type` TEXT, + `offline_operations_file_name` TEXT, + `offline_operations_created_at` INTEGER + ) + """ + ) + + execSQL( + """ + INSERT INTO offline_operations_new + SELECT _id, offline_operations_parent_oc_file_id, offline_operations_path, + offline_operations_type, offline_operations_file_name, offline_operations_created_at + FROM ${ProviderMeta.ProviderTableMeta.OFFLINE_OPERATION_TABLE_NAME} + """ + ) + + execSQL("DROP TABLE ${ProviderMeta.ProviderTableMeta.OFFLINE_OPERATION_TABLE_NAME}") + execSQL( + "ALTER TABLE offline_operations_new RENAME TO " + + ProviderMeta.ProviderTableMeta.OFFLINE_OPERATION_TABLE_NAME + ) + } + } +} diff --git a/app/src/main/java/com/nextcloud/utils/fileNameValidator/FileNameValidator.kt b/app/src/main/java/com/nextcloud/utils/fileNameValidator/FileNameValidator.kt index a7332da57660..c363864061a5 100644 --- a/app/src/main/java/com/nextcloud/utils/fileNameValidator/FileNameValidator.kt +++ b/app/src/main/java/com/nextcloud/utils/fileNameValidator/FileNameValidator.kt @@ -32,7 +32,7 @@ object FileNameValidator { * @param existedFileNames Set of existing file names to avoid duplicates. * @return An error message if the filename is invalid, null otherwise. */ - @Suppress("ReturnCount") + @Suppress("ReturnCount", "NestedBlockDepth") fun checkFileName( filename: String, capability: OCCapability, diff --git a/app/src/main/java/com/owncloud/android/ui/dialog/CreateFolderDialogFragment.kt b/app/src/main/java/com/owncloud/android/ui/dialog/CreateFolderDialogFragment.kt index e9197c542c4a..6642b025902a 100644 --- a/app/src/main/java/com/owncloud/android/ui/dialog/CreateFolderDialogFragment.kt +++ b/app/src/main/java/com/owncloud/android/ui/dialog/CreateFolderDialogFragment.kt @@ -192,8 +192,7 @@ class CreateFolderDialogFragment : DialogFragment(), DialogInterface.OnClickList parentFolder?.fileId ) - val fileDisplayActivity = requireActivity() as? FileDisplayActivity - fileDisplayActivity?.refreshCurrentDirectory() + typedActivity()?.refreshCurrentDirectory() } } }