Skip to content

Commit

Permalink
Fix: Fetch thumbnails on cache cleared (#736)
Browse files Browse the repository at this point in the history
  • Loading branch information
anilbeesetti authored Nov 15, 2023
1 parent 97f4b0c commit 561f5de
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class LocalMediaInfoSynchronizer @Inject constructor(
media.collect { mediumUri ->
val path = context.getPath(mediumUri) ?: return@collect
val medium = mediumDao.getWithInfo(path) ?: return@collect
if (medium.videoStreamInfo != null) return@collect
if (medium.mediumEntity.thumbnailPath?.let { File(it) }?.exists() == true) return@collect

Log.d(TAG, "sync: $mediumUri")

Expand All @@ -56,7 +56,7 @@ class LocalMediaInfoSynchronizer @Inject constructor(
val videoStreamInfo = mediaInfo.videoStream?.toVideoStreamInfoEntity(medium.mediumEntity.path)
val audioStreamsInfo = mediaInfo.audioStreams.map { it.toAudioStreamInfoEntity(medium.mediumEntity.path) }
val subtitleStreamsInfo = mediaInfo.subtitleStreams.map { it.toSubtitleStreamInfoEntity(medium.mediumEntity.path) }
val thumbnailPath = thumbnail?.saveTo(storageDir = context.filesDir, quality = 30)
val thumbnailPath = thumbnail?.saveTo(storageDir = context.cacheDir, quality = 30)

mediumDao.upsert(medium.mediumEntity.copy(format = mediaInfo.format, thumbnailPath = thumbnailPath))
videoStreamInfo?.let { mediumDao.upsertVideoStreamInfo(it) }
Expand Down

0 comments on commit 561f5de

Please sign in to comment.