mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Save files with "wt" #1282
This commit is contained in:
@@ -5,6 +5,7 @@ KeePassDX(3.4.0)
|
||||
* Add editable chars fields #539
|
||||
* Add color for special password chars #454
|
||||
* Passphrase implementation #218
|
||||
* Fix small bugs #1282
|
||||
|
||||
KeePassDX(3.3.3)
|
||||
* Fix shared otpauth link if database not open #1274
|
||||
|
||||
@@ -913,53 +913,24 @@ class Database {
|
||||
try {
|
||||
val saveUri = databaseCopyUri ?: this.fileUri
|
||||
if (saveUri != null) {
|
||||
if (saveUri.scheme == "file") {
|
||||
saveUri.path?.let { filename ->
|
||||
val tempFile = File("$filename.tmp")
|
||||
|
||||
var fileOutputStream: FileOutputStream? = null
|
||||
try {
|
||||
fileOutputStream = FileOutputStream(tempFile)
|
||||
val pmo = mDatabaseKDB?.let { DatabaseOutputKDB(it, fileOutputStream) }
|
||||
?: mDatabaseKDBX?.let { DatabaseOutputKDBX(it, fileOutputStream) }
|
||||
pmo?.output()
|
||||
} catch (e: Exception) {
|
||||
throw IOException(e)
|
||||
} finally {
|
||||
fileOutputStream?.close()
|
||||
}
|
||||
|
||||
// Force data to disk before continuing
|
||||
try {
|
||||
fileOutputStream?.fd?.sync()
|
||||
} catch (e: SyncFailedException) {
|
||||
// Ignore if fsync fails. We tried.
|
||||
}
|
||||
|
||||
if (!tempFile.renameTo(File(filename))) {
|
||||
throw IOException()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var outputStream: OutputStream? = null
|
||||
try {
|
||||
outputStream = contentResolver.openOutputStream(saveUri, "rwt")
|
||||
outputStream?.let { definedOutputStream ->
|
||||
val databaseOutput =
|
||||
mDatabaseKDB?.let { DatabaseOutputKDB(it, definedOutputStream) }
|
||||
?: mDatabaseKDBX?.let {
|
||||
DatabaseOutputKDBX(
|
||||
it,
|
||||
definedOutputStream
|
||||
)
|
||||
}
|
||||
databaseOutput?.output()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
throw IOException(e)
|
||||
} finally {
|
||||
outputStream?.close()
|
||||
var outputStream: OutputStream? = null
|
||||
try {
|
||||
outputStream = UriUtil.getUriOutputStream(contentResolver, saveUri)
|
||||
outputStream?.let { definedOutputStream ->
|
||||
val databaseOutput =
|
||||
mDatabaseKDB?.let { DatabaseOutputKDB(it, definedOutputStream) }
|
||||
?: mDatabaseKDBX?.let {
|
||||
DatabaseOutputKDBX(
|
||||
it,
|
||||
definedOutputStream
|
||||
)
|
||||
}
|
||||
databaseOutput?.output()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
throw IOException(e)
|
||||
} finally {
|
||||
outputStream?.close()
|
||||
}
|
||||
if (databaseCopyUri == null) {
|
||||
this.dataModifiedSinceLastLoading = false
|
||||
|
||||
@@ -69,7 +69,7 @@ object UriUtil {
|
||||
return null
|
||||
return when {
|
||||
isFileScheme(fileUri) -> fileUri.path?.let { FileOutputStream(it) }
|
||||
isContentScheme(fileUri) -> contentResolver.openOutputStream(fileUri, "rwt")
|
||||
isContentScheme(fileUri) -> contentResolver.openOutputStream(fileUri, "wt")
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,3 +4,4 @@
|
||||
* Add editable chars fields #539
|
||||
* Add color for special password chars #454
|
||||
* Passphrase implementation #218
|
||||
* Fix small bugs #1282
|
||||
@@ -4,3 +4,4 @@
|
||||
* Ajout de champs éditable de génération #539
|
||||
* Ajout des couleurs pour chaque caractère spécial de mots de passe #454
|
||||
* Phrases secrètes #218
|
||||
* Correction de petits bugs #1282
|
||||
Reference in New Issue
Block a user