Skip to content

Commit

Permalink
Skip download of PDFs that are already downloaded
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksonh committed Jul 1, 2024
1 parent 8e4e49e commit 09db09f
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ suspend fun saveLibraryItemContentToFile(context: Context, libraryItemId: String
var localPDFPath: String? = null
if (contentReader == ContentReader.PDF) {
val localPDFPath = "${libraryItemId}.pdf"
val file = File(context.filesDir, localPDFPath)
if (file.exists()) {
// TODO: there should really be a checksum check here
Log.d("PDF", "SKIPPING DOWNLOAD FOR LOCAL PDF PATH: ${localPDFPath}")
return true
}
withContext(Dispatchers.IO) {
val urlStream: InputStream = URL(contentUrl).openStream()
context.openFileOutput(localPDFPath, Context.MODE_PRIVATE).use { outputStream ->
Expand Down

0 comments on commit 09db09f

Please sign in to comment.