Try to recover from corrupt metadata cache
This commit is contained in:
parent
6428399bed
commit
81fae1a240
2 changed files with 7 additions and 2 deletions
|
@ -46,8 +46,12 @@ internal class MetadataManager(
|
||||||
field = try {
|
field = try {
|
||||||
getMetadataFromCache() ?: throw IOException()
|
getMetadataFromCache() ?: throw IOException()
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
// If this happens, it is hard to recover from this. Let's hope it never does.
|
// This can happen if the storage location ran out of space
|
||||||
throw AssertionError("Error reading metadata from cache", e)
|
// or the app process got killed while writing the file.
|
||||||
|
// It is hard to recover from this, so we try as best as we can here:
|
||||||
|
Log.e(TAG, "ERROR getting metadata cache, creating new file ", e)
|
||||||
|
// This should cause requiresInit() return true
|
||||||
|
uninitializedMetadata.copy(version = (-1).toByte())
|
||||||
}
|
}
|
||||||
mLastBackupTime.postValue(field.time)
|
mLastBackupTime.postValue(field.time)
|
||||||
}
|
}
|
||||||
|
|
|
@ -231,6 +231,7 @@ internal class BackupCoordinator(
|
||||||
): Int {
|
): Int {
|
||||||
state.cancelReason = UNKNOWN_ERROR
|
state.cancelReason = UNKNOWN_ERROR
|
||||||
if (metadataManager.requiresInit) {
|
if (metadataManager.requiresInit) {
|
||||||
|
Log.w(TAG, "Metadata requires re-init!")
|
||||||
// start a new restore set to upgrade from legacy format
|
// start a new restore set to upgrade from legacy format
|
||||||
// by starting a clean backup with all files using the new version
|
// by starting a clean backup with all files using the new version
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue