|
|
@ -76,32 +76,35 @@ object Backup { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Throws(java.lang.Exception::class) |
|
|
|
private fun copyBackup(context: Context, uri: Uri) { |
|
|
|
private fun copyBackup(context: Context, uri: Uri) { |
|
|
|
DocumentFile.fromTreeUri(context, uri)?.let { treeDoc -> |
|
|
|
DocumentFile.fromTreeUri(context, uri)?.let { treeDoc -> |
|
|
|
for (fileName in backupFileNames) { |
|
|
|
for (fileName in backupFileNames) { |
|
|
|
val doc = treeDoc.findFile(fileName) ?: treeDoc.createFile("", fileName) |
|
|
|
val file = File(backupPath + File.separator + fileName) |
|
|
|
doc?.let { |
|
|
|
if (file.exists()) { |
|
|
|
DocumentUtils.writeText( |
|
|
|
val doc = treeDoc.findFile(fileName) ?: treeDoc.createFile("", fileName) |
|
|
|
context, |
|
|
|
doc?.let { |
|
|
|
FileUtils.createFileIfNotExist(backupPath + File.separator + fileName).readText(), |
|
|
|
DocumentUtils.writeText( |
|
|
|
doc.uri |
|
|
|
context, |
|
|
|
) |
|
|
|
file.readText(), |
|
|
|
|
|
|
|
doc.uri |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun copyBackup(file: File) { |
|
|
|
@Throws(java.lang.Exception::class) |
|
|
|
try { |
|
|
|
private fun copyBackup(rootFile: File) { |
|
|
|
for (fileName in backupFileNames) { |
|
|
|
for (fileName in backupFileNames) { |
|
|
|
FileUtils.createFileIfNotExist(backupPath + File.separator + fileName) |
|
|
|
val file = File(backupPath + File.separator + fileName) |
|
|
|
.copyTo( |
|
|
|
if (file.exists()) { |
|
|
|
FileUtils.createFileIfNotExist(file, fileName), |
|
|
|
file.copyTo( |
|
|
|
true |
|
|
|
FileUtils.createFileIfNotExist(rootFile, fileName), |
|
|
|
) |
|
|
|
true |
|
|
|
|
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (e: Exception) { |
|
|
|
|
|
|
|
e.printStackTrace() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |