@@ -27,38 +27,34 @@ class ImportExportManager(private val fileLocator: BackupFileLocator) {
2727 fun exportDatabase (preferences : SharedPreferences , file : StoredFileHelper ) {
2828 file.create()
2929 ZipOutputStream (SharpOutputStream (file.stream).buffered()).use { outZip ->
30- try {
31- // add the database
32- ZipHelper .addFileToZip(
33- outZip,
34- BackupFileLocator .FILE_NAME_DB ,
35- fileLocator.db.path,
36- )
37-
38- // add the legacy vulnerable serialized preferences (will be removed in the future)
39- ZipHelper .addFileToZip(
40- outZip,
41- BackupFileLocator .FILE_NAME_SERIALIZED_PREFS
42- ) { byteOutput ->
43- ObjectOutputStream (byteOutput).use { output ->
44- output.writeObject(preferences.all)
45- output.flush()
46- }
30+ // add the database
31+ ZipHelper .addFileToZip(
32+ outZip,
33+ BackupFileLocator .FILE_NAME_DB ,
34+ fileLocator.db.path,
35+ )
36+
37+ // add the legacy vulnerable serialized preferences (will be removed in the future)
38+ ZipHelper .addFileToZip(
39+ outZip,
40+ BackupFileLocator .FILE_NAME_SERIALIZED_PREFS
41+ ) { byteOutput ->
42+ ObjectOutputStream (byteOutput).use { output ->
43+ output.writeObject(preferences.all)
44+ output.flush()
4745 }
46+ }
4847
49- // add the JSON preferences
50- ZipHelper .addFileToZip(
51- outZip,
52- BackupFileLocator .FILE_NAME_JSON_PREFS
53- ) { byteOutput ->
54- JsonWriter
55- .indent(" " )
56- .on(byteOutput)
57- .`object `(preferences.all)
58- .done()
59- }
60- } catch (e: Exception ) {
61- Log .e(TAG , " Unable to export serialized settings" , e)
48+ // add the JSON preferences
49+ ZipHelper .addFileToZip(
50+ outZip,
51+ BackupFileLocator .FILE_NAME_JSON_PREFS
52+ ) { byteOutput ->
53+ JsonWriter
54+ .indent(" " )
55+ .on(byteOutput)
56+ .`object `(preferences.all)
57+ .done()
6258 }
6359 }
6460 }
@@ -133,7 +129,7 @@ class ImportExportManager(private val fileLocator: BackupFileLocator) {
133129 }
134130
135131 if (! editor.commit()) {
136- Log .e( TAG , " Unable to loadSerializedPrefs" )
132+ throw IOException ( " Unable to commit loadSerializedPrefs" )
137133 }
138134 }
139135 }.let { fileExists ->
@@ -168,7 +164,7 @@ class ImportExportManager(private val fileLocator: BackupFileLocator) {
168164 }
169165
170166 if (! editor.commit()) {
171- Log .e( TAG , " Unable to loadJsonPrefs" )
167+ throw IOException ( " Unable to commit loadJsonPrefs" )
172168 }
173169 }.let { fileExists ->
174170 if (! fileExists) {
0 commit comments