all: reformat
This commit is contained in:
parent
acd4dab74c
commit
7b1ccfc3fb
5 changed files with 65 additions and 34 deletions
|
@ -20,6 +20,7 @@ package org.oxycblt.auxio.music
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||||
|
import java.util.UUID
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import kotlinx.coroutines.CancellationException
|
import kotlinx.coroutines.CancellationException
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
@ -29,10 +30,8 @@ import kotlinx.coroutines.yield
|
||||||
import org.oxycblt.auxio.music.MusicRepository.IndexingWorker
|
import org.oxycblt.auxio.music.MusicRepository.IndexingWorker
|
||||||
import org.oxycblt.musikr.IndexingProgress
|
import org.oxycblt.musikr.IndexingProgress
|
||||||
import org.oxycblt.musikr.Interpretation
|
import org.oxycblt.musikr.Interpretation
|
||||||
import org.oxycblt.musikr.Library
|
|
||||||
import org.oxycblt.musikr.Music
|
import org.oxycblt.musikr.Music
|
||||||
import org.oxycblt.musikr.Musikr
|
import org.oxycblt.musikr.Musikr
|
||||||
import org.oxycblt.musikr.MutableLibrary
|
|
||||||
import org.oxycblt.musikr.Playlist
|
import org.oxycblt.musikr.Playlist
|
||||||
import org.oxycblt.musikr.Song
|
import org.oxycblt.musikr.Song
|
||||||
import org.oxycblt.musikr.Storage
|
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.playlist.db.StoredPlaylists
|
||||||
import org.oxycblt.musikr.tag.interpret.Naming
|
import org.oxycblt.musikr.tag.interpret.Naming
|
||||||
import org.oxycblt.musikr.tag.interpret.Separators
|
import org.oxycblt.musikr.tag.interpret.Separators
|
||||||
import java.util.UUID
|
|
||||||
import timber.log.Timber as L
|
import timber.log.Timber as L
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -366,27 +364,28 @@ constructor(
|
||||||
|
|
||||||
val revision: UUID
|
val revision: UUID
|
||||||
val storage: Storage
|
val storage: Storage
|
||||||
if (withCache) {
|
if (withCache) {
|
||||||
revision = this.library?.revision ?: musicSettings.revision
|
revision = this.library?.revision ?: musicSettings.revision
|
||||||
storage = Storage(
|
storage =
|
||||||
|
Storage(
|
||||||
Cache.full(cacheDatabase),
|
Cache.full(cacheDatabase),
|
||||||
StoredCovers.from(context, "covers_$revision"),
|
StoredCovers.from(context, "covers_$revision"),
|
||||||
StoredPlaylists.from(playlistDatabase))
|
StoredPlaylists.from(playlistDatabase))
|
||||||
} else {
|
} else {
|
||||||
revision = UUID.randomUUID()
|
revision = UUID.randomUUID()
|
||||||
storage = Storage(
|
storage =
|
||||||
|
Storage(
|
||||||
Cache.writeOnly(cacheDatabase),
|
Cache.writeOnly(cacheDatabase),
|
||||||
StoredCovers.from(context, "covers_$revision"),
|
StoredCovers.from(context, "covers_$revision"),
|
||||||
StoredPlaylists.from(playlistDatabase))
|
StoredPlaylists.from(playlistDatabase))
|
||||||
}
|
}
|
||||||
|
|
||||||
val interpretation = Interpretation(nameFactory, separators)
|
val interpretation = Interpretation(nameFactory, separators)
|
||||||
|
|
||||||
val newLibrary =
|
val newLibrary =
|
||||||
Musikr.new(context, storage, interpretation).run(locations, ::emitIndexingProgress)
|
Musikr.new(context, storage, interpretation).run(locations, ::emitIndexingProgress)
|
||||||
|
|
||||||
val revisionedLibrary =
|
val revisionedLibrary = MutableRevisionedLibrary(revision, newLibrary)
|
||||||
MutableRevisionedLibrary(revision, newLibrary)
|
|
||||||
|
|
||||||
emitIndexingCompletion(null)
|
emitIndexingCompletion(null)
|
||||||
|
|
||||||
|
|
|
@ -21,11 +21,11 @@ package org.oxycblt.auxio.music
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.core.content.edit
|
import androidx.core.content.edit
|
||||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||||
|
import java.util.UUID
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import org.oxycblt.auxio.R
|
import org.oxycblt.auxio.R
|
||||||
import org.oxycblt.auxio.settings.Settings
|
import org.oxycblt.auxio.settings.Settings
|
||||||
import org.oxycblt.musikr.fs.MusicLocation
|
import org.oxycblt.musikr.fs.MusicLocation
|
||||||
import java.util.UUID
|
|
||||||
import timber.log.Timber as L
|
import timber.log.Timber as L
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -59,9 +59,10 @@ class MusicSettingsImpl @Inject constructor(@ApplicationContext private val cont
|
||||||
Settings.Impl<MusicSettings.Listener>(context), MusicSettings {
|
Settings.Impl<MusicSettings.Listener>(context), MusicSettings {
|
||||||
|
|
||||||
override var revision: UUID
|
override var revision: UUID
|
||||||
get() = UUID.fromString(
|
get() =
|
||||||
sharedPreferences.getString(getString(R.string.set_key_library_revision), null)
|
UUID.fromString(
|
||||||
?: UUID.randomUUID().toString())
|
sharedPreferences.getString(getString(R.string.set_key_library_revision), null)
|
||||||
|
?: UUID.randomUUID().toString())
|
||||||
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())
|
||||||
|
|
|
@ -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
|
package org.oxycblt.auxio.music
|
||||||
|
|
||||||
|
import java.util.UUID
|
||||||
import org.oxycblt.musikr.Library
|
import org.oxycblt.musikr.Library
|
||||||
import org.oxycblt.musikr.MutableLibrary
|
import org.oxycblt.musikr.MutableLibrary
|
||||||
import org.oxycblt.musikr.Playlist
|
import org.oxycblt.musikr.Playlist
|
||||||
import org.oxycblt.musikr.Song
|
import org.oxycblt.musikr.Song
|
||||||
import java.util.UUID
|
|
||||||
|
|
||||||
interface RevisionedLibrary : Library {
|
interface RevisionedLibrary : Library {
|
||||||
val revision: UUID
|
val revision: UUID
|
||||||
}
|
}
|
||||||
|
|
||||||
class MutableRevisionedLibrary(
|
class MutableRevisionedLibrary(override val revision: UUID, private val inner: MutableLibrary) :
|
||||||
override val revision: UUID,
|
RevisionedLibrary, Library by inner, MutableLibrary {
|
||||||
private val inner: MutableLibrary
|
|
||||||
) : RevisionedLibrary, Library by inner, MutableLibrary {
|
|
||||||
override suspend fun createPlaylist(name: String, songs: List<Song>) =
|
override suspend fun createPlaylist(name: String, songs: List<Song>) =
|
||||||
MutableRevisionedLibrary(revision, inner.createPlaylist(name, songs))
|
MutableRevisionedLibrary(revision, inner.createPlaylist(name, songs))
|
||||||
|
|
||||||
|
@ -28,5 +44,4 @@ class MutableRevisionedLibrary(
|
||||||
|
|
||||||
override suspend fun deletePlaylist(playlist: Playlist) =
|
override suspend fun deletePlaylist(playlist: Playlist) =
|
||||||
MutableRevisionedLibrary(revision, inner.deletePlaylist(playlist))
|
MutableRevisionedLibrary(revision, inner.deletePlaylist(playlist))
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
* 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.musikr.pipeline
|
package org.oxycblt.musikr.pipeline
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
@ -48,8 +48,7 @@ internal interface ExtractStep {
|
||||||
MetadataExtractor.from(context),
|
MetadataExtractor.from(context),
|
||||||
TagParser.new(),
|
TagParser.new(),
|
||||||
storage.cache,
|
storage.cache,
|
||||||
storage.storedCovers
|
storage.storedCovers)
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +70,9 @@ private class ExtractStepImpl(
|
||||||
val playlistNodes = filterFlow.left.map { ExtractedMusic.Playlist(it) }
|
val playlistNodes = filterFlow.left.map { ExtractedMusic.Playlist(it) }
|
||||||
|
|
||||||
val cacheResults =
|
val cacheResults =
|
||||||
audioNodes.map { wrap(it, cache::read) }.flowOn(Dispatchers.IO)
|
audioNodes
|
||||||
|
.map { wrap(it, cache::read) }
|
||||||
|
.flowOn(Dispatchers.IO)
|
||||||
.buffer(Channel.UNLIMITED)
|
.buffer(Channel.UNLIMITED)
|
||||||
val cacheFlow =
|
val cacheFlow =
|
||||||
cacheResults.divert {
|
cacheResults.divert {
|
||||||
|
@ -111,8 +112,7 @@ private class ExtractStepImpl(
|
||||||
cachedSongs,
|
cachedSongs,
|
||||||
distributedFlow.manager,
|
distributedFlow.manager,
|
||||||
writtenSongs,
|
writtenSongs,
|
||||||
playlistNodes
|
playlistNodes)
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
package org.oxycblt.musikr.pipeline
|
||||||
|
|
||||||
import org.oxycblt.musikr.fs.DeviceFile
|
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.playlist.interpret.PrePlaylist
|
||||||
import org.oxycblt.musikr.tag.interpret.PreSong
|
import org.oxycblt.musikr.tag.interpret.PreSong
|
||||||
|
|
||||||
class PipelineException(
|
class PipelineException(val processing: WhileProcessing, val error: Exception) : Exception() {
|
||||||
val processing: WhileProcessing,
|
|
||||||
val error: Exception
|
|
||||||
) : Exception() {
|
|
||||||
override val cause = error
|
override val cause = error
|
||||||
|
|
||||||
override val message = "Error while processing ${processing}: $error"
|
override val message = "Error while processing ${processing}: $error"
|
||||||
|
@ -31,7 +46,8 @@ sealed interface WhileProcessing {
|
||||||
override fun toString() = "Pre Song @ ${preSong.path}"
|
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}"
|
override fun toString() = "Pre Playlist @ ${prePlaylist.name}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue