fix: restore SAF metadata fallback and preserve active transfers

Propagate filesystem errors from complete metadata reads so Android retries unreadable SAF descriptors through temporary files while accepting valid audio without tags.

Keep established segmented and chunked transfers outside the resolution allowance. Continue charging initial requests, retries, and progress callbacks, including during parallel native reads, while preserving stall cancellation.

Add metadata, transfer, and native fallback regression tests. Validated with Go tests, race detector, vet, Android tests, targeted Flutter tests, analyzer, and formatting checks.
This commit is contained in:
zarzet
2026-09-06 16:43:24 +07:00
parent 717e8967cd
commit 781661798b
9 changed files with 327 additions and 30 deletions
@@ -6,6 +6,14 @@ import org.junit.Assert.assertNull
import org.junit.Test
class SafMetadataReadPolicyTest {
@Test fun completeMetadataReadErrorUsesTemporaryCopy() {
val metadata = mapOf("lyrics" to "words", "comment" to "notes", "track_number" to 3)
assertEquals(metadata, readSafMetadataWithFallback(
directRead = { throw Exception("failed to read metadata: permission denied") },
fallbackRead = { metadata },
))
}
@Test fun fallbackFailureIsIsolatedToOneFile() {
assertNull(readSafMetadataWithFallback<String>({ null }, { throw IllegalArgumentException("malformed metadata") }))
assertEquals("next file", readSafMetadataWithFallback({ "next file" }, { error("copy") }))