mirror of
https://github.com/gedoor/legado.git
synced 2024-08-30 09:23:26 +08:00
[skip ci] 优化
This commit is contained in:
parent
c48fdc5fbc
commit
d605d2f149
@ -290,7 +290,8 @@ object LocalBook {
|
|||||||
inputStream: InputStream,
|
inputStream: InputStream,
|
||||||
fileName: String
|
fileName: String
|
||||||
): Uri {
|
): Uri {
|
||||||
if (inputStream.isEmpty()) throw EmptyFileException("Unexpected empty inputStream")
|
inputStream.use {
|
||||||
|
if (it.isEmpty()) throw EmptyFileException("Unexpected empty inputStream")
|
||||||
val defaultBookTreeUri = AppConfig.defaultBookTreeUri
|
val defaultBookTreeUri = AppConfig.defaultBookTreeUri
|
||||||
if (defaultBookTreeUri.isNullOrBlank()) throw NoStackTraceException("没有设置书籍保存位置!")
|
if (defaultBookTreeUri.isNullOrBlank()) throw NoStackTraceException("没有设置书籍保存位置!")
|
||||||
val treeUri = Uri.parse(defaultBookTreeUri)
|
val treeUri = Uri.parse(defaultBookTreeUri)
|
||||||
@ -302,18 +303,19 @@ object LocalBook {
|
|||||||
?: throw SecurityException("请重新设置书籍保存位置\nPermission Denial")
|
?: throw SecurityException("请重新设置书籍保存位置\nPermission Denial")
|
||||||
}
|
}
|
||||||
appCtx.contentResolver.openOutputStream(doc.uri)!!.use { oStream ->
|
appCtx.contentResolver.openOutputStream(doc.uri)!!.use { oStream ->
|
||||||
inputStream.copyTo(oStream)
|
it.copyTo(oStream)
|
||||||
}
|
}
|
||||||
doc.uri
|
doc.uri
|
||||||
} else {
|
} else {
|
||||||
val treeFile = File(treeUri.path!!)
|
val treeFile = File(treeUri.path!!)
|
||||||
val file = treeFile.getFile(fileName)
|
val file = treeFile.getFile(fileName)
|
||||||
FileOutputStream(file).use { oStream ->
|
FileOutputStream(file).use { oStream ->
|
||||||
inputStream.copyTo(oStream)
|
it.copyTo(oStream)
|
||||||
}
|
}
|
||||||
Uri.fromFile(file)
|
Uri.fromFile(file)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun isOnBookShelf(
|
fun isOnBookShelf(
|
||||||
fileName: String
|
fileName: String
|
||||||
|
@ -17,7 +17,6 @@ import io.legado.app.data.entities.Book
|
|||||||
import io.legado.app.data.entities.BookChapter
|
import io.legado.app.data.entities.BookChapter
|
||||||
import io.legado.app.data.entities.BookSource
|
import io.legado.app.data.entities.BookSource
|
||||||
import io.legado.app.exception.NoStackTraceException
|
import io.legado.app.exception.NoStackTraceException
|
||||||
import io.legado.app.exception.EmptyFileException
|
|
||||||
import io.legado.app.help.AppWebDav
|
import io.legado.app.help.AppWebDav
|
||||||
import io.legado.app.help.book.*
|
import io.legado.app.help.book.*
|
||||||
import io.legado.app.help.coroutine.Coroutine
|
import io.legado.app.help.coroutine.Coroutine
|
||||||
|
Loading…
Reference in New Issue
Block a user