all: reformat

This commit is contained in:
Alexander Capehart 2024-12-17 16:05:13 -05:00
parent acd4dab74c
commit 7b1ccfc3fb
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
5 changed files with 65 additions and 34 deletions

View file

@ -20,6 +20,7 @@ package org.oxycblt.auxio.music
import android.content.Context
import dagger.hilt.android.qualifiers.ApplicationContext
import java.util.UUID
import javax.inject.Inject
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.Dispatchers
@ -29,10 +30,8 @@ import kotlinx.coroutines.yield
import org.oxycblt.auxio.music.MusicRepository.IndexingWorker
import org.oxycblt.musikr.IndexingProgress
import org.oxycblt.musikr.Interpretation
import org.oxycblt.musikr.Library
import org.oxycblt.musikr.Music
import org.oxycblt.musikr.Musikr
import org.oxycblt.musikr.MutableLibrary
import org.oxycblt.musikr.Playlist
import org.oxycblt.musikr.Song
import org.oxycblt.musikr.Storage
@ -43,7 +42,6 @@ import org.oxycblt.musikr.playlist.db.PlaylistDatabase
import org.oxycblt.musikr.playlist.db.StoredPlaylists
import org.oxycblt.musikr.tag.interpret.Naming
import org.oxycblt.musikr.tag.interpret.Separators
import java.util.UUID
import timber.log.Timber as L
/**
@ -366,27 +364,28 @@ constructor(
val revision: UUID
val storage: Storage
if (withCache) {
revision = this.library?.revision ?: musicSettings.revision
storage = Storage(
if (withCache) {
revision = this.library?.revision ?: musicSettings.revision
storage =
Storage(
Cache.full(cacheDatabase),
StoredCovers.from(context, "covers_$revision"),
StoredPlaylists.from(playlistDatabase))
} else {
revision = UUID.randomUUID()
storage = Storage(
} else {
revision = UUID.randomUUID()
storage =
Storage(
Cache.writeOnly(cacheDatabase),
StoredCovers.from(context, "covers_$revision"),
StoredPlaylists.from(playlistDatabase))
}
}
val interpretation = Interpretation(nameFactory, separators)
val newLibrary =
Musikr.new(context, storage, interpretation).run(locations, ::emitIndexingProgress)
val revisionedLibrary =
MutableRevisionedLibrary(revision, newLibrary)
val revisionedLibrary = MutableRevisionedLibrary(revision, newLibrary)
emitIndexingCompletion(null)

View file

@ -21,11 +21,11 @@ package org.oxycblt.auxio.music
import android.content.Context
import androidx.core.content.edit
import dagger.hilt.android.qualifiers.ApplicationContext
import java.util.UUID
import javax.inject.Inject
import org.oxycblt.auxio.R
import org.oxycblt.auxio.settings.Settings
import org.oxycblt.musikr.fs.MusicLocation
import java.util.UUID
import timber.log.Timber as L
/**
@ -59,9 +59,10 @@ class MusicSettingsImpl @Inject constructor(@ApplicationContext private val cont
Settings.Impl<MusicSettings.Listener>(context), MusicSettings {
override var revision: UUID
get() = UUID.fromString(
sharedPreferences.getString(getString(R.string.set_key_library_revision), null)
?: UUID.randomUUID().toString())
get() =
UUID.fromString(
sharedPreferences.getString(getString(R.string.set_key_library_revision), null)
?: UUID.randomUUID().toString())
set(value) {
sharedPreferences.edit {
putString(getString(R.string.set_key_library_revision), value.toString())

View file

@ -1,19 +1,35 @@
/*
* Copyright (c) 2024 Auxio Project
* RevisionedLibrary.kt is part of Auxio.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.oxycblt.auxio.music
import java.util.UUID
import org.oxycblt.musikr.Library
import org.oxycblt.musikr.MutableLibrary
import org.oxycblt.musikr.Playlist
import org.oxycblt.musikr.Song
import java.util.UUID
interface RevisionedLibrary : Library {
val revision: UUID
}
class MutableRevisionedLibrary(
override val revision: UUID,
private val inner: MutableLibrary
) : RevisionedLibrary, Library by inner, MutableLibrary {
class MutableRevisionedLibrary(override val revision: UUID, private val inner: MutableLibrary) :
RevisionedLibrary, Library by inner, MutableLibrary {
override suspend fun createPlaylist(name: String, songs: List<Song>) =
MutableRevisionedLibrary(revision, inner.createPlaylist(name, songs))
@ -28,5 +44,4 @@ class MutableRevisionedLibrary(
override suspend fun deletePlaylist(playlist: Playlist) =
MutableRevisionedLibrary(revision, inner.deletePlaylist(playlist))
}
}

View file

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.oxycblt.musikr.pipeline
import android.content.Context
@ -48,8 +48,7 @@ internal interface ExtractStep {
MetadataExtractor.from(context),
TagParser.new(),
storage.cache,
storage.storedCovers
)
storage.storedCovers)
}
}
@ -71,7 +70,9 @@ private class ExtractStepImpl(
val playlistNodes = filterFlow.left.map { ExtractedMusic.Playlist(it) }
val cacheResults =
audioNodes.map { wrap(it, cache::read) }.flowOn(Dispatchers.IO)
audioNodes
.map { wrap(it, cache::read) }
.flowOn(Dispatchers.IO)
.buffer(Channel.UNLIMITED)
val cacheFlow =
cacheResults.divert {
@ -111,8 +112,7 @@ private class ExtractStepImpl(
cachedSongs,
distributedFlow.manager,
writtenSongs,
playlistNodes
)
playlistNodes)
}
}

View file

@ -1,3 +1,21 @@
/*
* Copyright (c) 2024 Auxio Project
* PipelineException.kt is part of Auxio.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.oxycblt.musikr.pipeline
import org.oxycblt.musikr.fs.DeviceFile
@ -5,10 +23,7 @@ import org.oxycblt.musikr.playlist.PlaylistFile
import org.oxycblt.musikr.playlist.interpret.PrePlaylist
import org.oxycblt.musikr.tag.interpret.PreSong
class PipelineException(
val processing: WhileProcessing,
val error: Exception
) : Exception() {
class PipelineException(val processing: WhileProcessing, val error: Exception) : Exception() {
override val cause = error
override val message = "Error while processing ${processing}: $error"
@ -31,7 +46,8 @@ sealed interface WhileProcessing {
override fun toString() = "Pre Song @ ${preSong.path}"
}
class APrePlaylist internal constructor(private val prePlaylist: PrePlaylist) : WhileProcessing {
class APrePlaylist internal constructor(private val prePlaylist: PrePlaylist) :
WhileProcessing {
override fun toString() = "Pre Playlist @ ${prePlaylist.name}"
}
}