Update UniFile
Which has more correct nullability for some methods and case insensitivity for listFiles where possible.
This commit is contained in:
@@ -37,8 +37,8 @@ class DownloadProvider(
|
||||
internal fun getMangaDir(mangaTitle: String, source: Source): UniFile {
|
||||
try {
|
||||
return downloadsDir!!
|
||||
.createDirectory(getSourceDirName(source))
|
||||
.createDirectory(getMangaDirName(mangaTitle))
|
||||
.createDirectory(getSourceDirName(source))!!
|
||||
.createDirectory(getMangaDirName(mangaTitle))!!
|
||||
} catch (e: Throwable) {
|
||||
logcat(LogPriority.ERROR, e) { "Invalid download directory" }
|
||||
throw Exception(context.stringResource(MR.strings.invalid_location, downloadsDir ?: ""))
|
||||
|
||||
@@ -335,7 +335,7 @@ class Downloader(
|
||||
}
|
||||
|
||||
val chapterDirname = provider.getChapterDirName(download.chapter.name, download.chapter.scanlator)
|
||||
val tmpDir = mangaDir.createDirectory(chapterDirname + TMP_DIR_SUFFIX)
|
||||
val tmpDir = mangaDir.createDirectory(chapterDirname + TMP_DIR_SUFFIX)!!
|
||||
|
||||
try {
|
||||
// If the page list already exists, start from the file
|
||||
@@ -480,7 +480,7 @@ class Downloader(
|
||||
page.progress = 0
|
||||
return flow {
|
||||
val response = source.getImage(page)
|
||||
val file = tmpDir.createFile("$filename.tmp")
|
||||
val file = tmpDir.createFile("$filename.tmp")!!
|
||||
try {
|
||||
response.body.source().saveTo(file.openOutputStream())
|
||||
val extension = getImageExtension(response, file)
|
||||
@@ -512,7 +512,7 @@ class Downloader(
|
||||
* @param filename the filename of the image.
|
||||
*/
|
||||
private fun copyImageFromCache(cacheFile: File, tmpDir: UniFile, filename: String): UniFile {
|
||||
val tmpFile = tmpDir.createFile("$filename.tmp")
|
||||
val tmpFile = tmpDir.createFile("$filename.tmp")!!
|
||||
cacheFile.inputStream().use { input ->
|
||||
tmpFile.openOutputStream().use { output ->
|
||||
input.copyTo(output)
|
||||
@@ -603,7 +603,7 @@ class Downloader(
|
||||
dirname: String,
|
||||
tmpDir: UniFile,
|
||||
) {
|
||||
val zip = mangaDir.createFile("$dirname.cbz$TMP_DIR_SUFFIX")
|
||||
val zip = mangaDir.createFile("$dirname.cbz$TMP_DIR_SUFFIX")!!
|
||||
ZipOutputStream(BufferedOutputStream(zip.openOutputStream())).use { zipOut ->
|
||||
zipOut.setMethod(ZipEntry.STORED)
|
||||
|
||||
@@ -643,7 +643,7 @@ class Downloader(
|
||||
val comicInfo = getComicInfo(manga, chapter, chapterUrl, categories)
|
||||
// Remove the old file
|
||||
dir.findFile(COMIC_INFO_FILE)?.delete()
|
||||
dir.createFile(COMIC_INFO_FILE).openOutputStream().use {
|
||||
dir.createFile(COMIC_INFO_FILE)!!.openOutputStream().use {
|
||||
val comicInfoString = xml.encodeToString(ComicInfo.serializer(), comicInfo)
|
||||
it.write(comicInfoString.toByteArray())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user