fix(download): explain filesystem failures and prepare the import dir
A failing Files.createDirectories only produced the directory path in the log, which hid whether the music hostPath was read-only or owned by another user. Errors now include the exception type, cause and a hint about UID 10001, and permission or read-only failures fail immediately instead of retrying three times. The chart gets a prepare-imports init container (downloads.prepare) that creates "<music>/AudioManager Imports" and gives it to UID 10001, so downloads work on a hostPath owned by root. Chart version 0.2.4.
This commit is contained in:
1 parent
a5af1ee83f
commit
e7704c42ea
6 files changed
+114
-8
No files matched your search
@@ -1,5 +1,6 @@
|
||||
package win.taptap.musicmanager.download
|
||||
|
||||
import java.nio.file.AccessDeniedException
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.time.Instant
|
||||
@@ -142,6 +143,42 @@ class DownloadServiceTest {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun `permission errors fail without burning retries`() {
|
||||
withDatabase { _, library, users ->
|
||||
val mood = MoodRepository.create(
|
||||
owner = "alice",
|
||||
name = "Denied",
|
||||
description = null,
|
||||
query = null,
|
||||
genres = emptyList(),
|
||||
targetSize = 30,
|
||||
refreshHours = 24,
|
||||
ytEnabled = true,
|
||||
seedSongIds = emptyList(),
|
||||
)
|
||||
DownloadRepository.enqueue("alice", mood.id, "v-3", "Blocked", "Nobody")
|
||||
val service = DownloadService(
|
||||
users = users,
|
||||
library = library,
|
||||
downloader = AudioDownloader { _, _, _, _ ->
|
||||
throw AccessDeniedException("/mnt/media/music/AudioManager Imports")
|
||||
},
|
||||
tempDir = tempDir.resolve("downloads"),
|
||||
startScan = { true },
|
||||
isScanning = { false },
|
||||
)
|
||||
|
||||
assertTrue(service.processOne())
|
||||
|
||||
val job = assertNotNull(DownloadRepository.forRecommendation("alice", mood.id, "v-3"))
|
||||
assertEquals("failed", job.state)
|
||||
assertEquals(1, job.attempts)
|
||||
assertTrue(job.error?.contains("AccessDeniedException") == true)
|
||||
}
|
||||
}
|
||||
|
||||
private fun withDatabase(block: (DatabaseHandle, LibraryConfig, UsersConfig) -> Unit) {
|
||||
val musicDir = Files.createDirectories(tempDir.resolve("music"))
|
||||
val library = LibraryConfig(
|
||||
|
||||
Reference in new issue
Block a user