mirror of
https://github.com/gedoor/legado.git
synced 2024-07-06 23:47:49 +08:00
优化
This commit is contained in:
parent
6cd087be87
commit
aabb73477e
@ -263,6 +263,8 @@ class CacheActivity : VMBaseActivity<ActivityCacheBookBinding, CacheViewModel>()
|
||||
val path = ACache.get().getAsString(exportBookPathKey)
|
||||
if (path.isNullOrEmpty()) {
|
||||
selectExportFolder(position)
|
||||
} else if (FileDoc.fromUri(path.parseToUri(), true).checkWrite() != true) {
|
||||
selectExportFolder(position)
|
||||
} else if (enableCustomExport()) {// 启用自定义导出 and 导出类型为Epub
|
||||
configExportSection(path, position)
|
||||
} else {
|
||||
|
@ -274,7 +274,7 @@ class BackupConfigFragment : PreferenceFragment(),
|
||||
if (backupPath.isContentScheme()) {
|
||||
val uri = Uri.parse(backupPath)
|
||||
val doc = DocumentFile.fromTreeUri(requireContext(), uri)
|
||||
if (doc?.canWrite() == true) {
|
||||
if (doc?.checkWrite() == true) {
|
||||
waitDialog.setText("备份中…")
|
||||
waitDialog.setOnCancelListener {
|
||||
backupJob?.cancel()
|
||||
|
@ -287,6 +287,16 @@ fun FileDoc.delete() {
|
||||
asDocumentFile()?.delete()
|
||||
}
|
||||
|
||||
fun FileDoc.checkWrite(): Boolean? {
|
||||
if (!isDir) {
|
||||
throw NoStackTraceException("只能检查目录")
|
||||
}
|
||||
asFile()?.let {
|
||||
return it.checkWrite()
|
||||
}
|
||||
return asDocumentFile()?.checkWrite()
|
||||
}
|
||||
|
||||
/**
|
||||
* DocumentFile 的 listFiles() 非常的慢,尽量不要使用
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user