From 751504c214d63fdbb84d20c708ab6d095e948468 Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Fri, 27 Sep 2024 11:23:18 -0300 Subject: [PATCH] improve local metadata handling --- .../com/stevesoltys/seedvault/metadata/MetadataManager.kt | 7 ++++--- .../com/stevesoltys/seedvault/settings/AppListRetriever.kt | 6 ------ 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/stevesoltys/seedvault/metadata/MetadataManager.kt b/app/src/main/java/com/stevesoltys/seedvault/metadata/MetadataManager.kt index bab7ca72..72bf8b9e 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/metadata/MetadataManager.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/metadata/MetadataManager.kt @@ -36,14 +36,15 @@ internal class MetadataManager( get() { if (field == uninitializedMetadata) { field = try { - getMetadataFromCache() ?: throw IOException() + val m = getMetadataFromCache() ?: throw IOException() + if (m == uninitializedMetadata) m.copy(salt = "initialized") + else m } catch (e: IOException) { // This can happen if the storage location ran out of space // 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()) + uninitializedMetadata.copy(salt = "initialized") } } return field diff --git a/app/src/main/java/com/stevesoltys/seedvault/settings/AppListRetriever.kt b/app/src/main/java/com/stevesoltys/seedvault/settings/AppListRetriever.kt index 66a43275..da127149 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/settings/AppListRetriever.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/settings/AppListRetriever.kt @@ -9,7 +9,6 @@ import android.annotation.StringRes import android.content.Context import android.content.pm.PackageManager import android.graphics.drawable.Drawable -import android.util.Log import androidx.annotation.WorkerThread import androidx.appcompat.content.res.AppCompatResources.getDrawable import com.stevesoltys.seedvault.R @@ -30,8 +29,6 @@ import com.stevesoltys.seedvault.ui.notification.getAppName import com.stevesoltys.seedvault.ui.systemData import java.util.Locale -private const val TAG = "AppListRetriever" - sealed class AppListItem data class AppStatus( @@ -97,9 +94,6 @@ internal class AppListRetriever( val metadata = metadataManager.getPackageMetadata(it.packageName) val time = metadata?.time ?: 0 val status = metadata?.state.toAppBackupState() - if (status == NOT_YET_BACKED_UP) { - Log.w(TAG, "No metadata available for: ${it.packageName}") - } AppStatus( packageName = it.packageName, enabled = settingsManager.isBackupEnabled(it.packageName),