Skip to content

Commit 5062a02

Browse files
committed
Inline CollectionOperations.clearMediaAndTrash()
Only one usage, simple two line method.
1 parent 0e388a8 commit 5062a02

File tree

2 files changed

+4
-16
lines changed

2 files changed

+4
-16
lines changed

AnkiDroid/src/main/java/com/ichi2/anki/ui/windows/managespace/ManageSpaceFragment.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ import com.ichi2.anki.ui.dialogs.tools.DialogResult
4444
import com.ichi2.anki.ui.dialogs.tools.awaitDialog
4545
import com.ichi2.anki.utils.getUserFriendlyErrorText
4646
import com.ichi2.anki.withProgress
47-
import com.ichi2.async.clearMediaAndTrash
4847
import com.ichi2.preferences.TextWidgetPreference
4948
import kotlinx.coroutines.CoroutineScope
5049
import kotlinx.coroutines.Dispatchers
@@ -110,7 +109,10 @@ class ManageSpaceViewModel(
110109

111110
suspend fun deleteMediaFiles(filesNamesToDelete: List<String>) {
112111
try {
113-
withCol { clearMediaAndTrash(this@withCol, filesNamesToDelete) }
112+
withCol {
113+
media.trashFiles(filesNamesToDelete)
114+
media.emptyTrash()
115+
}
114116
} finally {
115117
launchCalculationOfSizeOfEverything()
116118
launchCalculationOfCollectionSize()

AnkiDroid/src/main/java/com/ichi2/async/CollectionOperations.kt

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,6 @@ import com.ichi2.anki.libanki.Collection
2222
import com.ichi2.anki.libanki.NotetypeJson
2323
import timber.log.Timber
2424

25-
/**
26-
* Trashes the specified media files and immediately empties the trash in the given [Collection].
27-
*
28-
* @param col The [Collection] from which media files should be removed.
29-
* @param unused A list of media file names to be deleted.
30-
*/
31-
fun clearMediaAndTrash(
32-
col: Collection,
33-
unused: List<String>,
34-
) {
35-
col.media.trashFiles(unused)
36-
col.media.emptyTrash()
37-
}
38-
3925
/**
4026
* Handles everything for a note type change at once - template add / deletes as well as content updates
4127
*/

0 commit comments

Comments
 (0)