Update UniFile
Which has more correct nullability for some methods and case insensitivity for listFiles where possible. (cherry picked from commit a74a689c9048cc67f4854678fbfefa361631a5e7) # Conflicts: # app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt # source-local/src/androidMain/kotlin/tachiyomi/source/local/image/LocalCoverManager.kt
This commit is contained in:
parent
2bb0ee9543
commit
c2d2295149
@ -101,8 +101,9 @@ object SettingsDataScreen : SearchableSettings {
|
||||
|
||||
context.contentResolver.takePersistableUriPermission(uri, flags)
|
||||
|
||||
val file = UniFile.fromUri(context, uri)
|
||||
storageDirPref.set(file.uri.toString())
|
||||
UniFile.fromUri(context, uri)?.let {
|
||||
storageDirPref.set(it.uri.toString())
|
||||
}
|
||||
Injekt.get<DownloadCache>().invalidateCache()
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ class BackupCreateJob(private val context: Context, workerParams: WorkerParamete
|
||||
if (isAutoBackup) {
|
||||
backupPreferences.lastAutoBackupTimestamp().set(Date().time)
|
||||
} else {
|
||||
notifier.showBackupComplete(UniFile.fromUri(context, location.toUri()))
|
||||
notifier.showBackupComplete(UniFile.fromUri(context, location.toUri())!!)
|
||||
}
|
||||
Result.success()
|
||||
} catch (e: Exception) {
|
||||
|
@ -122,14 +122,14 @@ class BackupCreator(
|
||||
val dir = UniFile.fromUri(context, uri)
|
||||
|
||||
// Delete older backups
|
||||
dir.listFiles { _, filename -> Backup.filenameRegex.matches(filename) }
|
||||
dir?.listFiles { _, filename -> Backup.filenameRegex.matches(filename) }
|
||||
.orEmpty()
|
||||
.sortedByDescending { it.name }
|
||||
.drop(MAX_AUTO_BACKUPS - 1)
|
||||
.forEach { it.delete() }
|
||||
|
||||
// Create new file to place backup
|
||||
dir.createFile(Backup.getFilename())
|
||||
dir?.createFile(Backup.getFilename())
|
||||
} else {
|
||||
UniFile.fromUri(context, uri)
|
||||
}
|
||||
|
@ -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 ?: ""))
|
||||
|
@ -348,7 +348,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
|
||||
@ -504,7 +504,7 @@ class Downloader(
|
||||
page.progress = 0
|
||||
return flow {
|
||||
val response = source.getImage(page, dataSaver)
|
||||
val file = tmpDir.createFile("$filename.tmp")
|
||||
val file = tmpDir.createFile("$filename.tmp")!!
|
||||
try {
|
||||
response.body.source().saveTo(file.openOutputStream())
|
||||
val extension = getImageExtension(response, file)
|
||||
@ -536,7 +536,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)
|
||||
@ -642,7 +642,7 @@ class Downloader(
|
||||
}
|
||||
// SY <--
|
||||
|
||||
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)
|
||||
|
||||
@ -721,7 +721,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())
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ fun Context.createReaderThemeContext(): Context {
|
||||
* @return document size of [uri] or null if size can't be obtained
|
||||
*/
|
||||
fun Context.getUriSize(uri: Uri): Long? {
|
||||
return UniFile.fromUri(this, uri).length().takeIf { it >= 0 }
|
||||
return UniFile.fromUri(this, uri)?.length()?.takeIf { it >= 0 }
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -337,7 +337,7 @@ object ImageUtil {
|
||||
// Remove pre-existing split if exists (this split shouldn't exist under normal circumstances)
|
||||
tmpDir.findFile(splitImageName)?.delete()
|
||||
|
||||
val splitFile = tmpDir.createFile(splitImageName)
|
||||
val splitFile = tmpDir.createFile(splitImageName)!!
|
||||
|
||||
val region = Rect(0, splitData.topOffset, splitData.splitWidth, splitData.bottomOffset)
|
||||
|
||||
|
@ -30,7 +30,7 @@ quickjs-android = "app.cash.quickjs:quickjs-android:0.9.2"
|
||||
jsoup = "org.jsoup:jsoup:1.16.2"
|
||||
|
||||
disklrucache = "com.jakewharton:disklrucache:2.0.2"
|
||||
unifile = "com.github.tachiyomiorg:unifile:17bec43"
|
||||
unifile = "com.github.tachiyomiorg:unifile:7c257e1c64"
|
||||
junrar = "com.github.junrar:junrar:7.5.5"
|
||||
zip4j = "net.lingala.zip4j:zip4j:2.11.5"
|
||||
|
||||
|
@ -58,7 +58,6 @@ actual class LocalCoverManager(
|
||||
|
||||
targetFile!!
|
||||
|
||||
// It might not exist at this point
|
||||
inputStream.use { input ->
|
||||
// SY -->
|
||||
if (encrypted) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user