优化
This commit is contained in:
@@ -151,13 +151,13 @@ object Backup {
|
|||||||
if (ZipUtils.zipFiles(paths, zipFilePath)) {
|
if (ZipUtils.zipFiles(paths, zipFilePath)) {
|
||||||
when {
|
when {
|
||||||
path.isNullOrBlank() -> {
|
path.isNullOrBlank() -> {
|
||||||
copyBackup(context.getExternalFilesDir(null)!!, zipFileName)
|
copyBackup(context.getExternalFilesDir(null)!!, "backup.zip")
|
||||||
}
|
}
|
||||||
path.isContentScheme() -> {
|
path.isContentScheme() -> {
|
||||||
copyBackup(context, Uri.parse(path), zipFileName)
|
copyBackup(context, Uri.parse(path), "backup.zip")
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
copyBackup(File(path), zipFileName)
|
copyBackup(File(path), "backup.zip")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AppWebDav.backUpWebDav(zipFileName)
|
AppWebDav.backUpWebDav(zipFileName)
|
||||||
@@ -175,6 +175,7 @@ object Backup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
|
@Suppress("SameParameterValue")
|
||||||
private fun copyBackup(context: Context, uri: Uri, fileName: String) {
|
private fun copyBackup(context: Context, uri: Uri, fileName: String) {
|
||||||
DocumentFile.fromTreeUri(context, uri)?.let { treeDoc ->
|
DocumentFile.fromTreeUri(context, uri)?.let { treeDoc ->
|
||||||
treeDoc.findFile(fileName)?.delete()
|
treeDoc.findFile(fileName)?.delete()
|
||||||
@@ -187,6 +188,7 @@ object Backup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
|
@Suppress("SameParameterValue")
|
||||||
private fun copyBackup(rootFile: File, fileName: String) {
|
private fun copyBackup(rootFile: File, fileName: String) {
|
||||||
FileInputStream(File(zipFilePath)).use { inputS ->
|
FileInputStream(File(zipFilePath)).use { inputS ->
|
||||||
val file = FileUtils.createFileIfNotExist(rootFile, fileName)
|
val file = FileUtils.createFileIfNotExist(rootFile, fileName)
|
||||||
|
|||||||
Reference in New Issue
Block a user