mirror of
https://github.com/gedoor/legado.git
synced 2024-08-30 09:23:26 +08:00
优化
This commit is contained in:
parent
785bd0b43d
commit
070f235e63
@ -151,13 +151,13 @@ object Backup {
|
||||
if (ZipUtils.zipFiles(paths, zipFilePath)) {
|
||||
when {
|
||||
path.isNullOrBlank() -> {
|
||||
copyBackup(context.getExternalFilesDir(null)!!, zipFileName)
|
||||
copyBackup(context.getExternalFilesDir(null)!!, "backup.zip")
|
||||
}
|
||||
path.isContentScheme() -> {
|
||||
copyBackup(context, Uri.parse(path), zipFileName)
|
||||
copyBackup(context, Uri.parse(path), "backup.zip")
|
||||
}
|
||||
else -> {
|
||||
copyBackup(File(path), zipFileName)
|
||||
copyBackup(File(path), "backup.zip")
|
||||
}
|
||||
}
|
||||
AppWebDav.backUpWebDav(zipFileName)
|
||||
@ -175,6 +175,7 @@ object Backup {
|
||||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
@Suppress("SameParameterValue")
|
||||
private fun copyBackup(context: Context, uri: Uri, fileName: String) {
|
||||
DocumentFile.fromTreeUri(context, uri)?.let { treeDoc ->
|
||||
treeDoc.findFile(fileName)?.delete()
|
||||
@ -187,6 +188,7 @@ object Backup {
|
||||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
@Suppress("SameParameterValue")
|
||||
private fun copyBackup(rootFile: File, fileName: String) {
|
||||
FileInputStream(File(zipFilePath)).use { inputS ->
|
||||
val file = FileUtils.createFileIfNotExist(rootFile, fileName)
|
||||
|
Loading…
Reference in New Issue
Block a user