Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
briar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julian Dehm
briar
Commits
b410b8ef
Verified
Commit
b410b8ef
authored
6 years ago
by
akwizgran
Browse files
Options
Downloads
Patches
Plain Diff
Don't overwrite the backup if it's our only copy.
parent
39aa2d96
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
briar-android/src/main/java/org/briarproject/briar/android/controller/ConfigControllerImpl.java
+10
-5
10 additions, 5 deletions
...roject/briar/android/controller/ConfigControllerImpl.java
with
10 additions
and
5 deletions
briar-android/src/main/java/org/briarproject/briar/android/controller/ConfigControllerImpl.java
+
10
−
5
View file @
b410b8ef
...
...
@@ -116,22 +116,27 @@ public class ConfigControllerImpl implements ConfigController {
LOG
.
info
(
"Storing database key in file"
);
File
dbKey
=
getDbKeyFile
();
File
dbKeyBackup
=
getDbKeyBackupFile
();
// Create the directory if necessary
if
(
databaseConfig
.
getDatabaseKeyDirectory
().
mkdirs
())
LOG
.
info
(
"Created database key directory"
);
// If only the backup file exists, rename it so we don't overwrite it
if
(
dbKeyBackup
.
exists
()
&&
!
dbKey
.
exists
())
{
if
(
dbKeyBackup
.
renameTo
(
dbKey
))
LOG
.
info
(
"Renamed old backup"
);
else
LOG
.
warning
(
"Failed to rename old backup"
);
}
try
{
// Create the directory if necessary
if
(
databaseConfig
.
getDatabaseKeyDirectory
().
mkdirs
())
LOG
.
info
(
"Created database key directory"
);
// Write to the backup file
FileOutputStream
out
=
new
FileOutputStream
(
dbKeyBackup
);
out
.
write
(
hex
.
getBytes
(
"UTF-8"
));
out
.
flush
();
out
.
close
();
LOG
.
info
(
"Stored database key in backup file"
);
// Delete the old
ke
y file, if it exists
// Delete the old
primar
y file, if it exists
if
(
dbKey
.
exists
())
{
if
(
dbKey
.
delete
())
LOG
.
info
(
"Deleted primary file"
);
else
LOG
.
warning
(
"Failed to delete primary file"
);
}
// The backup file becomes the new
key file
// The backup file becomes the new
primary
boolean
renamed
=
dbKeyBackup
.
renameTo
(
dbKey
);
if
(
renamed
)
LOG
.
info
(
"Renamed backup file to primary"
);
else
LOG
.
warning
(
"Failed to rename backup file to primary"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment