Skip to content

Commit

Permalink
Ignore all ExoPlayer caches on error
Browse files Browse the repository at this point in the history
I suspect this can cause issues if the remote item is taken down due to a label
request.
  • Loading branch information
stoyicker committed Aug 19, 2024
1 parent 53d60b8 commit 0d07fd0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ internal class CacheKeyAesCipherDataSourceFactoryFactory(
fun create(cache: Cache) = CacheKeyAesCipherDataSourceFactory(
cacheKeyFactory,
encryption!!.secretKey,
cacheDataSourceFactory.setCache(cache),
cacheDataSourceFactory.setCache(cache)
.setFlags(CacheDataSource.FLAG_IGNORE_CACHE_ON_ERROR),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ internal class OfflinePlayDrmDataSourceFactoryHelper(
) : OfflineDataSourceFactoryHelper<DataSource.Factory>(offlineCacheProvider) {

override fun create(cache: Cache) = cacheDataSourceFactory.setCache(cache)
.setFlags(CacheDataSource.FLAG_IGNORE_CACHE_ON_ERROR)
}
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ internal object MediaSourcererModule {
.setUpstreamDataSourceFactory(okHttpDataSourceFactory)
.setCacheReadDataSourceFactory(fileDataSourceFactory)
.setCacheWriteDataSinkFactory(cacheDataSinkFactory)
.setFlags(CacheDataSource.FLAG_IGNORE_CACHE_ON_ERROR)
}

@Provides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@ internal class OfflinePlayDrmDataSourceFactoryHelperTest {
fun create() {
val cache = mock<Cache>()
whenever(cacheDataSourceFactory.setCache(cache)).thenReturn(cacheDataSourceFactory)
whenever(cacheDataSourceFactory.setFlags(CacheDataSource.FLAG_IGNORE_CACHE_ON_ERROR))
.thenReturn(cacheDataSourceFactory)

val actualDataSourceFactory = offlinePlayDrmDataSourceFactoryHelper.create(cache)

assertThat(actualDataSourceFactory).isSameAs(cacheDataSourceFactory)
verify(cacheDataSourceFactory).setCache(cache)
verify(cacheDataSourceFactory).setFlags(CacheDataSource.FLAG_IGNORE_CACHE_ON_ERROR)
verifyNoMoreInteractions(
cache,
cacheDataSourceFactory,
Expand Down

0 comments on commit 0d07fd0

Please sign in to comment.