Skip to content

Commit 0e388a8

Browse files
committed
Inline CollectionOperations.deleteMedia()
Only one usage, simple method.
1 parent 4fcb0a6 commit 0e388a8

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

AnkiDroid/src/main/java/com/ichi2/anki/mediacheck/MediaCheckViewModel.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import anki.media.CheckMediaResponse
2323
import com.ichi2.anki.CollectionManager.withCol
2424
import com.ichi2.anki.common.annotations.NeedsTest
2525
import com.ichi2.anki.observability.undoableOp
26-
import com.ichi2.async.deleteMedia
2726
import kotlinx.coroutines.Job
2827
import kotlinx.coroutines.flow.MutableStateFlow
2928
import kotlinx.coroutines.flow.StateFlow
@@ -69,7 +68,8 @@ class MediaCheckViewModel : ViewModel() {
6968
// TODO: investigate: the underlying implementation exposes progress, which we do not yet handle.
7069
fun deleteUnusedMedia(): Job =
7170
viewModelScope.launch {
72-
val deletedMedia = withCol { deleteMedia(this@withCol, _mediaCheckResult.value?.unusedList ?: listOf()) }
73-
deletedFilesCount.value = deletedMedia
71+
val unused = _mediaCheckResult.value?.unusedList ?: listOf()
72+
withCol { media.trashFiles(unused) }
73+
deletedFilesCount.value = unused.size
7474
}
7575
}

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

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

25-
/**
26-
* Takes a list of media file names and removes them from the [Collection]
27-
* @param unused List of media names to be deleted
28-
*/
29-
fun deleteMedia(
30-
col: Collection,
31-
unused: List<String>,
32-
): Int {
33-
col.media.trashFiles(unused)
34-
return unused.size
35-
}
36-
3725
/**
3826
* Trashes the specified media files and immediately empties the trash in the given [Collection].
3927
*

0 commit comments

Comments
 (0)