improve local metadata handling
This commit is contained in:
parent
eea65d4082
commit
751504c214
2 changed files with 4 additions and 9 deletions
|
@ -36,14 +36,15 @@ internal class MetadataManager(
|
||||||
get() {
|
get() {
|
||||||
if (field == uninitializedMetadata) {
|
if (field == uninitializedMetadata) {
|
||||||
field = try {
|
field = try {
|
||||||
getMetadataFromCache() ?: throw IOException()
|
val m = getMetadataFromCache() ?: throw IOException()
|
||||||
|
if (m == uninitializedMetadata) m.copy(salt = "initialized")
|
||||||
|
else m
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
// This can happen if the storage location ran out of space
|
// This can happen if the storage location ran out of space
|
||||||
// or the app process got killed while writing the file.
|
// 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:
|
// 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)
|
Log.e(TAG, "ERROR getting metadata cache, creating new file ", e)
|
||||||
// This should cause requiresInit() return true
|
uninitializedMetadata.copy(salt = "initialized")
|
||||||
uninitializedMetadata.copy(version = (-1).toByte())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return field
|
return field
|
||||||
|
|
|
@ -9,7 +9,6 @@ import android.annotation.StringRes
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.util.Log
|
|
||||||
import androidx.annotation.WorkerThread
|
import androidx.annotation.WorkerThread
|
||||||
import androidx.appcompat.content.res.AppCompatResources.getDrawable
|
import androidx.appcompat.content.res.AppCompatResources.getDrawable
|
||||||
import com.stevesoltys.seedvault.R
|
import com.stevesoltys.seedvault.R
|
||||||
|
@ -30,8 +29,6 @@ import com.stevesoltys.seedvault.ui.notification.getAppName
|
||||||
import com.stevesoltys.seedvault.ui.systemData
|
import com.stevesoltys.seedvault.ui.systemData
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
|
||||||
private const val TAG = "AppListRetriever"
|
|
||||||
|
|
||||||
sealed class AppListItem
|
sealed class AppListItem
|
||||||
|
|
||||||
data class AppStatus(
|
data class AppStatus(
|
||||||
|
@ -97,9 +94,6 @@ internal class AppListRetriever(
|
||||||
val metadata = metadataManager.getPackageMetadata(it.packageName)
|
val metadata = metadataManager.getPackageMetadata(it.packageName)
|
||||||
val time = metadata?.time ?: 0
|
val time = metadata?.time ?: 0
|
||||||
val status = metadata?.state.toAppBackupState()
|
val status = metadata?.state.toAppBackupState()
|
||||||
if (status == NOT_YET_BACKED_UP) {
|
|
||||||
Log.w(TAG, "No metadata available for: ${it.packageName}")
|
|
||||||
}
|
|
||||||
AppStatus(
|
AppStatus(
|
||||||
packageName = it.packageName,
|
packageName = it.packageName,
|
||||||
enabled = settingsManager.isBackupEnabled(it.packageName),
|
enabled = settingsManager.isBackupEnabled(it.packageName),
|
||||||
|
|
Loading…
Reference in a new issue