Keep DNS retry safe for WebSockets and preserve saved user edits
All checks were successful
review/security-claude Blocking finding fixed on 052d0b88; delta reviewed

This commit is contained in:
justinzeus 2026-11-07 01:23:33 +01:00
parent 327f631f0d
commit 052d0b8898
10 changed files with 144 additions and 17 deletions

View file

@ -51,6 +51,10 @@ interface JellyfinServerDao {
return user.copy(rowId = result.toInt())
}
/** Network name refreshes must not overwrite settings or protection changed since launch. */
@Query("UPDATE users SET name = :name WHERE serverId = :serverId AND id = :userId")
fun updateUserName(serverId: UUID, userId: UUID, name: String?): Int
@Query("SELECT * FROM users WHERE serverId = :serverId AND id = :userId")
fun getUser(
serverId: UUID,

View file

@ -138,7 +138,8 @@ class ServerRepository
val (server, userDto) = readSession(expected.server)
if (_current.value !== expected || userDto.id != expected.user.id) return@withContext
serverDao.addOrUpdateServer(server)
val user = serverDao.addOrUpdateUser(expected.user.copy(name = userDto.name))
serverDao.updateUserName(expected.server.id, expected.user.id, userDto.name)
val user = serverDao.getUser(expected.server.id, expected.user.id) ?: return@withContext
if (_current.compareAndSet(expected, CurrentUser(server, user))) updateUserDto(userDto)
}

View file

@ -97,11 +97,11 @@ object AppModule {
fun okHttpClient(dns: PersistentDns) =
DnsConnectionRetry.configure(OkHttpClient.Builder(), dns).build()
/** Resolve filesDir lazily: Android may create it and lookup always runs off main. */
/** Resolve noBackupFilesDir lazily: Android may create it and lookup always runs off main. */
@Provides
@Singleton
fun dns(@ApplicationContext context: Context): PersistentDns =
PersistentDns(file = { File(context.filesDir, "wolfskin-dns.json") })
PersistentDns(file = { File(context.noBackupFilesDir, "wolfskin-dns.json") })
@AuthOkHttpClient
@Provides