Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion readium/lcp/src/main/java/org/readium/r2/lcp/LcpService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.readium.r2.lcp.auth.LcpDialogAuthentication
import org.readium.r2.lcp.license.model.LicenseDocument
import org.readium.r2.lcp.persistence.LcpDatabase
import org.readium.r2.lcp.service.CRLService
import org.readium.r2.lcp.service.DeviceRepository
Expand Down Expand Up @@ -137,7 +138,9 @@ public interface LcpService {
*/
public data class AcquiredPublication(
val localFile: File,
val suggestedFilename: String
val suggestedFilename: String,
val mediaType: MediaType,
val licenseDocument: LicenseDocument
) {
@Deprecated("Use `localFile` instead", replaceWith = ReplaceWith("localFile"), level = DeprecationLevel.ERROR)
val localURL: String get() = localFile.path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,9 @@ internal class LicensesService(

return LcpService.AcquiredPublication(
localFile = destination,
suggestedFilename = "${license.id}.${mediaType.fileExtension}"
suggestedFilename = "${license.id}.${mediaType.fileExtension}",
mediaType = mediaType,
licenseDocument = license
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public data class DomRange(
}
}

@Deprecated("Renamed into [charOffset]", ReplaceWith("charOffset"))
@Deprecated("Renamed into [charOffset]", ReplaceWith("charOffset"), level = DeprecationLevel.ERROR)
val offset: Long? get() = charOffset?.toLong()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public val Properties.indirectAcquisitions: List<Acquisition>
}
?: emptyList()

@Deprecated("Use [indirectAcquisitions] instead.", ReplaceWith("indirectAcquisitions"))
@Deprecated("Use [indirectAcquisitions] instead.", ReplaceWith("indirectAcquisitions"), level = DeprecationLevel.ERROR)
public val Properties.indirectAcquisition: List<Acquisition>
get() = indirectAcquisitions

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,13 @@ class BookRepository(
.fold(
{
val file = it.localFile
val asset = assetRetriever.retrieve(file, fileExtension = File(it.suggestedFilename).extension)
val asset = assetRetriever.retrieve(
file.toUrl(),
assetType = AssetType.Archive,
mediaType = it.mediaType
).getOrElse { error ->
return Try.failure(ImportError.PublicationError(error))
}
file to asset
},
{
Expand All @@ -254,15 +260,6 @@ class BookRepository(
)
}

if (publicationTempAsset == null) {
val exception = Publication.OpeningException.UnsupportedAsset("Unsupported media type")
return Try.failure(
ImportError.PublicationError(
PublicationError.UnsupportedPublication(exception)
)
)
}

val fileName = "${UUID.randomUUID()}.${publicationTempAsset.mediaType.fileExtension}"
val libraryFile = File(storageDir, fileName)
val libraryUrl = libraryFile.toUrl()
Expand Down