From 689450fad902114a97f7238c483e8cc13c188b9e Mon Sep 17 00:00:00 2001 From: gagip Date: Thu, 26 Mar 2026 02:18:59 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20QueueSnapshotDataStore=20=ED=8A=B8?= =?UTF-8?q?=EB=9E=99=20URI=20=EC=A7=81=EB=A0=AC=ED=99=94=EB=A5=BC=20JSONAr?= =?UTF-8?q?ray=EB=A1=9C=20=EA=B5=90=EC=B2=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - '|||' 구분자 방식은 URI에 특수문자가 포함될 경우 파싱 오류 발생 위험 - org.json.JSONArray(Android SDK 기본 제공)로 교체하여 데이터 무결성 보장 - SEPARATOR 상수 제거 --- .../zenplayer/core/datastore/QueueSnapshotDataStore.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/happyseal/zenplayer/core/datastore/QueueSnapshotDataStore.kt b/app/src/main/java/com/happyseal/zenplayer/core/datastore/QueueSnapshotDataStore.kt index 9c8b04cf..204b70e1 100644 --- a/app/src/main/java/com/happyseal/zenplayer/core/datastore/QueueSnapshotDataStore.kt +++ b/app/src/main/java/com/happyseal/zenplayer/core/datastore/QueueSnapshotDataStore.kt @@ -13,6 +13,7 @@ import com.happyseal.zenplayer.LogMusic import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.map +import org.json.JSONArray private val Context.queueDataStore: DataStore by preferencesDataStore( name = "zenplayer_queue_snapshot", @@ -33,7 +34,7 @@ class QueueSnapshotDataStore( */ suspend fun saveQueueSnapshot(snapshot: QueueSnapshot) { dataStore.edit { prefs -> - prefs[KEY_TRACK_URIS] = snapshot.trackUris.joinToString(SEPARATOR) + prefs[KEY_TRACK_URIS] = JSONArray(snapshot.trackUris).toString() prefs[KEY_CURRENT_INDEX] = snapshot.currentIndex prefs[KEY_POSITION_MS] = snapshot.positionMs } @@ -50,7 +51,8 @@ class QueueSnapshotDataStore( }.map { prefs -> val urisRaw = prefs[KEY_TRACK_URIS] ?: return@map null if (urisRaw.isBlank()) return@map null - val uris = urisRaw.split(SEPARATOR).filter { it.isNotBlank() } + val jsonArray = JSONArray(urisRaw) + val uris = List(jsonArray.length()) { jsonArray.getString(it) }.filter { it.isNotBlank() } if (uris.isEmpty()) return@map null QueueSnapshot( @@ -76,7 +78,6 @@ class QueueSnapshotDataStore( private val KEY_TRACK_URIS = stringPreferencesKey("queue_track_uris") private val KEY_CURRENT_INDEX = intPreferencesKey("queue_current_index") private val KEY_POSITION_MS = longPreferencesKey("queue_position_ms") - private const val SEPARATOR = "|||" } }