Skip to content

Commit

Permalink
remove scoped storage migration
Browse files Browse the repository at this point in the history
  • Loading branch information
BrayanDSO committed Aug 27, 2024
1 parent bc75f07 commit c77881d
Show file tree
Hide file tree
Showing 56 changed files with 7 additions and 6,354 deletions.
5 changes: 0 additions & 5 deletions AnkiDroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ android {
buildConfigField "String", "ACRA_URL", '"https://ankidroid.org/acra/report"'
buildConfigField "String", "BACKEND_VERSION", "\"${libs.versions.ankiBackend.get()}\""
buildConfigField "Boolean", "ENABLE_LEAK_CANARY", "false"
buildConfigField "Boolean", "ALLOW_UNSAFE_MIGRATION", "false"
buildConfigField "String", "GIT_COMMIT_HASH", "\"${gitCommitHash()}\""
buildConfigField "long", "BUILD_TIME", System.currentTimeMillis().toString()
resValue "string", "app_name", "AnkiDroid"
Expand Down Expand Up @@ -127,10 +126,6 @@ android {
if (localProperties['enable_languages'] == "false") {
android.defaultConfig.resConfigs "en"
}
// allows the scoped storage migration when the user is not logged in
if (localProperties["allow_unsafe_migration"] != null) {
buildConfigField "Boolean", "ALLOW_UNSAFE_MIGRATION", localProperties["allow_unsafe_migration"]
}
// allow disabling leak canary
if (localProperties["enable_leak_canary"] != null) {
buildConfigField "Boolean", "ENABLE_LEAK_CANARY", localProperties["enable_leak_canary"]
Expand Down
4 changes: 0 additions & 4 deletions AnkiDroid/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -483,10 +483,6 @@
<!-- Service to perform web API queries -->
<service android:name="com.ichi2.widget.AnkiDroidWidgetSmall$UpdateService" />

<service
android:name="com.ichi2.anki.services.MigrationService"
android:foregroundServiceType="dataSync"
/>

<!-- Don't disable/enable the widgets here until min API>=31, see issue #15747 & https://issuetracker.google.com/issues/36914010 -->
<!-- small widget -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ import com.ichi2.anki.reviewer.MotionEventHandler
import com.ichi2.anki.reviewer.PreviousAnswerIndicator
import com.ichi2.anki.servicelayer.LanguageHintService.applyLanguageHint
import com.ichi2.anki.servicelayer.NoteService.isMarked
import com.ichi2.anki.services.migrationServiceWhileStartedOrNull
import com.ichi2.anki.snackbar.BaseSnackbarBuilderProvider
import com.ichi2.anki.snackbar.SnackbarBuilder
import com.ichi2.anki.snackbar.showSnackbar
Expand Down Expand Up @@ -334,8 +333,6 @@ abstract class AbstractFlashcardViewer :
displayCardAnswer()
}

internal val migrationService by migrationServiceWhileStartedOrNull()

/**
* Changes which were received when the viewer was in the background
* which should be executed once the viewer is visible again
Expand Down Expand Up @@ -2334,10 +2331,6 @@ abstract class AbstractFlashcardViewer :
view: WebView,
request: WebResourceRequest
): WebResourceResponse? {
val url = request.url
if (url.toString().startsWith("file://")) {
url.path?.let { path -> migrationService?.migrateFileImmediately(File(path)) }
}
resourceHandler.shouldInterceptRequest(request)?.let { return it }
return null
}
Expand Down
23 changes: 0 additions & 23 deletions AnkiDroid/src/main/java/com/ichi2/anki/CollectionManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,10 @@
package com.ichi2.anki

import android.annotation.SuppressLint
import android.content.Context
import androidx.annotation.VisibleForTesting
import androidx.annotation.WorkerThread
import anki.backend.backendError
import com.ichi2.anki.common.utils.android.isRobolectric
import com.ichi2.anki.servicelayer.ValidatedMigrationSourceAndDestination
import com.ichi2.anki.servicelayer.scopedstorage.MigrateEssentialFiles
import com.ichi2.libanki.Collection
import com.ichi2.libanki.Storage.collection
import com.ichi2.libanki.importCollectionPackage
Expand Down Expand Up @@ -377,26 +374,6 @@ object CollectionManager {
}
}

/** Migrate collection and media databases to scoped storage.
* * Closes the collection, and performs the work in our queue so no
* other code can open the collection while the operation runs. Reopens
* at the end, and rolls back the path change if reopening fails.
*/
suspend fun migrateEssentialFiles(context: Context, folders: ValidatedMigrationSourceAndDestination) {
withQueue {
ensureClosedInner()
val migrator = MigrateEssentialFiles(context, folders)
migrator.migrateFiles()
migrator.updateCollectionPath()
try {
ensureOpenInner()
} catch (e: Exception) {
migrator.restoreOldCollectionPath()
throw e
}
}
}

fun setTestDispatcher(dispatcher: CoroutineDispatcher) {
// note: we avoid the call to .limitedParallelism() here,
// as it does not seem to be compatible with the test scheduler
Expand Down
Loading

0 comments on commit c77881d

Please sign in to comment.