app: reformat

This commit is contained in:
Alexander Capehart 2024-12-24 14:26:03 -05:00
parent 0cfd6ddb67
commit a24d102a00
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
3 changed files with 15 additions and 10 deletions

View file

@ -25,7 +25,6 @@ import javax.inject.Inject
import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
import kotlinx.coroutines.selects.select
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import kotlinx.coroutines.yield import kotlinx.coroutines.yield
import org.oxycblt.auxio.music.MusicRepository.IndexingWorker import org.oxycblt.auxio.music.MusicRepository.IndexingWorker
@ -410,7 +409,8 @@ constructor(
} }
// Old cover revisions may be lying around, even during a normal refresh due // Old cover revisions may be lying around, even during a normal refresh due
// to realyl lucky cancellations. Clean those up. // to really lucky cancellations. Clean those up now that it's impossible for
// the rest of the app to be using them.
RevisionedStoredCovers.cleanup(context, newRevision) RevisionedStoredCovers.cleanup(context, newRevision)
} }

View file

@ -60,7 +60,9 @@ class MusicSettingsImpl @Inject constructor(@ApplicationContext private val cont
override var revision: UUID? override var revision: UUID?
get() = get() =
sharedPreferences.getString(getString(R.string.set_key_library_revision), null)?.let(UUID::fromString) sharedPreferences
.getString(getString(R.string.set_key_library_revision), null)
?.let(UUID::fromString)
set(value) { set(value) {
sharedPreferences.edit { sharedPreferences.edit {
putString(getString(R.string.set_key_library_revision), value.toString()) putString(getString(R.string.set_key_library_revision), value.toString())

View file

@ -15,19 +15,18 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package org.oxycblt.auxio.music package org.oxycblt.auxio.music
import android.content.Context import android.content.Context
import java.util.UUID
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import java.util.UUID
import org.oxycblt.auxio.util.unlikelyToBeNull import org.oxycblt.auxio.util.unlikelyToBeNull
import org.oxycblt.musikr.cover.Cover import org.oxycblt.musikr.cover.Cover
import org.oxycblt.musikr.cover.CoverFormat import org.oxycblt.musikr.cover.CoverFormat
import org.oxycblt.musikr.cover.MutableStoredCovers import org.oxycblt.musikr.cover.MutableStoredCovers
import org.oxycblt.musikr.cover.StoredCovers import org.oxycblt.musikr.cover.StoredCovers
import java.io.File
open class RevisionedStoredCovers(private val context: Context, private val revision: UUID?) : open class RevisionedStoredCovers(private val context: Context, private val revision: UUID?) :
StoredCovers { StoredCovers {
@ -53,10 +52,14 @@ open class RevisionedStoredCovers(private val context: Context, private val revi
} }
companion object { companion object {
suspend fun cleanup(context: Context, exclude: UUID) = withContext(Dispatchers.IO) { suspend fun cleanup(context: Context, exclude: UUID) =
context.filesDir.listFiles { file -> file.name.startsWith("covers_") && file.name != "covers_$exclude" } withContext(Dispatchers.IO) {
?.forEach { it.deleteRecursively() } context.filesDir
} .listFiles { file ->
file.name.startsWith("covers_") && file.name != "covers_$exclude"
}
?.forEach { it.deleteRecursively() }
}
} }
} }