Skip to content

Commit

Permalink
remove housekeeping moment, it's not worth to risk the one and only b…
Browse files Browse the repository at this point in the history
…ackup
  • Loading branch information
hg42 committed Oct 16, 2022
1 parent 4529fc5 commit eb1d4c0
Show file tree
Hide file tree
Showing 35 changed files with 5 additions and 171 deletions.
24 changes: 0 additions & 24 deletions app/src/main/java/com/machiav3lli/backup/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -247,27 +247,3 @@ val BACKUP_DIRECTORY_INTENT = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE)
fun classAddress(address: String): String = PREFS_SHARED_PRIVATE + address

fun exodusUrl(app: String): String = "https://reports.exodus-privacy.eu.org/reports/$app/latest"


const val HOUSEKEEPING_BEFORE = 0
const val HOUSEKEEPING_AFTER = 1

val housekeepingOptions = mapOf(
HOUSEKEEPING_BEFORE to R.string.prefs_housekeepingmoment_before,
HOUSEKEEPING_AFTER to R.string.prefs_housekeepingmoment_after
)

enum class HousekeepingMoment(val value: String) {
BEFORE("before"), AFTER("after");

companion object {
fun fromString(value: String): HousekeepingMoment {
for (enumValue in values()) {
if (enumValue.value == value) {
return enumValue
}
}
throw IllegalArgumentException("No constant with value '$value'")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package com.machiav3lli.backup.handler
import android.content.Context
import android.content.pm.PackageManager
import com.machiav3lli.backup.BuildConfig
import com.machiav3lli.backup.HousekeepingMoment
import com.machiav3lli.backup.MODE_APK
import com.machiav3lli.backup.MODE_DATA
import com.machiav3lli.backup.actions.BackupAppAction
Expand All @@ -34,7 +33,6 @@ import com.machiav3lli.backup.items.ActionResult
import com.machiav3lli.backup.items.Package
import com.machiav3lli.backup.items.StorageFile
import com.machiav3lli.backup.items.StorageFile.Companion.invalidateCache
import com.machiav3lli.backup.preferences.pref_housekeepingMoment
import com.machiav3lli.backup.preferences.pref_numBackupRevisions
import com.machiav3lli.backup.tasks.AppActionWork
import com.machiav3lli.backup.utils.FileUtils.BackupLocationInAccessibleException
Expand All @@ -55,10 +53,7 @@ object BackupRestoreHelper {
backupMode: Int
): ActionResult {
var reBackupMode = backupMode
val housekeepingWhen = pref_housekeepingMoment.value
if (housekeepingWhen == HousekeepingMoment.BEFORE.ordinal) {
housekeepingPackageBackups(packageItem, true)
}

// Select and prepare the action to use
val action: BackupAppAction = when {
packageItem.isSpecial -> {
Expand All @@ -84,9 +79,8 @@ object BackupRestoreHelper {
Timber.i("[${packageItem.packageName}] Backup FAILED: ${result.succeeded} ${result.message}")
}

if (housekeepingWhen == HousekeepingMoment.AFTER.ordinal) {
housekeepingPackageBackups(packageItem, false)
}
housekeepingPackageBackups(packageItem)

return result
}

Expand Down Expand Up @@ -145,20 +139,14 @@ object BackupRestoreHelper {
return true
}

fun housekeepingPackageBackups(app: Package, before: Boolean) {
fun housekeepingPackageBackups(app: Package) {
var numBackupRevisions =
pref_numBackupRevisions.value
if (numBackupRevisions == 0) {
Timber.i("[${app.packageName}] Infinite backup revisions configured. Not deleting any backup.")
return
}

// If the backup is going to be created, reduce the number of backup revisions by one.
// It's expected that the additional deleted backup will be created in the next moments.
// HousekeepingMoment.AFTER does not need to change anything. If 2 backups are the limit,
// 3 should exist and housekeeping will work fine without adjustments
if (before) numBackupRevisions--

app.deleteOldestBackups(numBackupRevisions)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import com.machiav3lli.backup.R
import com.machiav3lli.backup.dialogs.BaseDialog
import com.machiav3lli.backup.dialogs.EnumDialogUI
import com.machiav3lli.backup.dialogs.StringDialogUI
import com.machiav3lli.backup.housekeepingOptions
import com.machiav3lli.backup.preferences.ui.PrefsGroup
import com.machiav3lli.backup.ui.compose.icons.Phosphor
import com.machiav3lli.backup.ui.compose.icons.phosphor.FileZip
Expand All @@ -33,7 +32,6 @@ import com.machiav3lli.backup.ui.compose.icons.phosphor.ShieldCheckered
import com.machiav3lli.backup.ui.compose.icons.phosphor.ShieldStar
import com.machiav3lli.backup.ui.compose.icons.phosphor.TagSimple
import com.machiav3lli.backup.ui.compose.icons.phosphor.Textbox
import com.machiav3lli.backup.ui.compose.icons.phosphor.TrashSimple
import com.machiav3lli.backup.ui.compose.theme.AppTheme
import com.machiav3lli.backup.ui.compose.theme.ColorAPK
import com.machiav3lli.backup.ui.compose.theme.ColorData
Expand Down Expand Up @@ -211,13 +209,3 @@ val pref_excludeCache = BooleanPref(
icon = Phosphor.Prohibit,
defaultValue = false
)

val pref_housekeepingMoment = EnumPref(
key = "srv.housekeepingMoment",
titleId = R.string.prefs_housekeepingmoment,
summaryId = R.string.prefs_housekeepingmoment_summary,
icon = Phosphor.TrashSimple,
//iconTint = MaterialTheme.colorScheme.secondary,
entries = housekeepingOptions,
defaultValue = 0
)
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.snapshots.SnapshotStateMap
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import com.machiav3lli.backup.MODE_ALL
Expand Down Expand Up @@ -160,7 +159,7 @@ fun MainPackageContextMenu(
expanded.value = false
val packages = selectedWithBackups
packages.onEach {
BackupRestoreHelper.housekeepingPackageBackups(it, false)
BackupRestoreHelper.housekeepingPackageBackups(it)
selection[it] = false
}
}
Expand Down
4 changes: 0 additions & 4 deletions app/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
<string name="batchrestore">استعادة متعددة</string>
<string name="batchbackup">نسخ احتياطي متعدد</string>
<string name="refresh">تحديث</string>
<string name="prefs_housekeepingmoment">وقت تنظيف النسخ</string>
<string name="prefs_numBackupRevisions_summary">سيتم حذف النسخة الأقدم عند إنشاء نسخة احتياطية جديدة إذا تم تجاوز الرقم. اضبطه على صفر للاحتفاظ بجميع المراجعات.</string>
<string name="prefs_numBackupRevisions">عدد النسخ الاحتياطية</string>
<string name="prefs_deviceprotecteddata_summary">النسخ الاحتياطي واستعادة البيانات التي يتم وضعها في data / user_de</string>
Expand Down Expand Up @@ -78,8 +77,6 @@
<string name="prefs_language_system">افتراضي النظام</string>
<string name="prefs_languages">اللغة</string>
<string name="prefs_theme_system">ثيم النظام</string>
<string name="prefs_housekeepingmoment_before">قبل النسخ الاحتياطي</string>
<string name="prefs_housekeepingmoment_after">بعد النسخ الاحتياطي</string>
<string name="prefs_theme_dark">داكن</string>
<string name="prefs_theme_light">فاتح</string>
<string name="prefs_theme">الثيم</string>
Expand Down Expand Up @@ -181,7 +178,6 @@
<string name="prefs_disableverification_summary">تعطيل خيار المطور هذا أثناء استعادة ملفات APK وإعادة تمكينه بعد ذلك. حل للخطأ: INSTALL_FAILED_VERIFICATION_FAILURE.</string>
<string name="prefs_disableverification">تعطيل التحقق من التطبيقات عبر USB</string>
<string name="prefs_acquirewakelock">منع النوم</string>
<string name="prefs_housekeepingmoment_summary">تحديد إن وجب حذف أقدم نسخة احتياطية قبل أو بعد إنشاء نسخة احتياطية جديدة لتحرير مساحة القرص التي تستخدمها النسخة الاحتياطية.</string>
<string name="prefs_enablespecial_summary">لا تزال بحاجة إلى اختبار مكثف، حاول مع أخذ الأعتبار بالخطورة بانه قد يتسبب في حدوث اعادة اقلاع متكرر(بوتلوب). الردود دائمًا موضع ترحيب.</string>
<string name="prefs_devicelock_summary">تأمين التطبيق باستخدام القفل الخاص بالجهاز</string>
<string name="prefs_devicelock">قفل الجهاز</string>
Expand Down
4 changes: 0 additions & 4 deletions app/src/main/res/values-ca/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,6 @@
<string name="prefs_disableverification">Desactiva la verificació d\'aplicacions mitjançant USB</string>
<string name="prefs_acquirewakelock_summary">Adquiriu un \"manteniu despert\" durant les operacions per lots per evitar el son. Accelera considerablement les còpies de seguretat i les restauracions, però consumeix més energia.</string>
<string name="prefs_acquirewakelock">Prevenir el son</string>
<string name="prefs_housekeepingmoment_summary">Configura si la revisió més antiga se suprimeix abans o després de crear una còpia de seguretat nova per alliberar l\'espai en disc utilitzat per la còpia de seguretat.</string>
<string name="prefs_housekeepingmoment">Temps de neteja de la revisió</string>
<string name="prefs_numBackupRevisions_summary">La revisió més antiga se suprimirà quan es creï una nova còpia de seguretat si se supera el nombre. Establiu-lo a zero per mantenir totes les revisions.</string>
<string name="prefs_numBackupRevisions">Nombre de revisions de còpia de seguretat</string>
<string name="prefs_deviceprotecteddata_summary">Fa una còpia de seguretat i restaura les dades que es col·loquen a data/user_de</string>
Expand Down Expand Up @@ -188,8 +186,6 @@
<string name="prefs_language_system">Sistema per defecte</string>
<string name="prefs_languages">Idioma</string>
<string name="prefs_theme_system">Tema del sistema</string>
<string name="prefs_housekeepingmoment_before">Abans de la còpia de seguretat</string>
<string name="prefs_housekeepingmoment_after">Després de la còpia de seguretat</string>
<string name="prefs_theme_dark">Fosc</string>
<string name="prefs_theme_light">Clar</string>
<string name="prefs_theme">Tema</string>
Expand Down
4 changes: 0 additions & 4 deletions app/src/main/res/values-cs/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
<string name="radio_system">Systémové aplikace</string>
<string name="radio_both">APK a data</string>
<string name="radio_data">Data</string>
<string name="prefs_housekeepingmoment_after">Po záloze</string>
<string name="restoreSuccess">Obnovení dokončeno</string>
<string name="prefs_advanced">Pokročilé předvolby</string>
<string name="prefs_enablespecial">Povolit speciální zálohy</string>
Expand Down Expand Up @@ -92,7 +91,6 @@
<string name="prefs_user">Uživatelské předvolby</string>
<string name="prefs_user_short">Osobní</string>
<string name="prefs_service">Předvolby služeb</string>
<string name="prefs_housekeepingmoment_before">Před zálohou</string>
<string name="prefs_theme_system">Motiv systému</string>
<string name="prefs_theme_dynamic">Dynamický motiv (pokud je dostupný)</string>
<string name="prefs_languages">Jazyk</string>
Expand Down Expand Up @@ -123,7 +121,6 @@
<string name="prefs_mediadata">Zálohovat média</string>
<string name="prefs_mediadata_summary">Zálohuje a obnoví média aplikací, které jsou uloženy na externím úložišti (např. /storage/emulated/0/Android/media/)</string>
<string name="prefs_installerpackagename">Název balíčku instalátoru:</string>
<string name="prefs_housekeepingmoment_summary">Nastavuje, zda se nejstarší revize odstraní před nebo po vytvoření nové zálohy, aby se uvolnilo místo na disku, které záloha využívá.</string>
<string name="prefs_compression_level">Úroveň komprese</string>
<string name="prefs_compression_level_summary">Nižší hodnota se zkomprimuje rychleji, ale výsledkem jsou větší soubory. Vyšší hodnota komprimuje lépe, ale trvá to déle.</string>
<string name="prefs_disableverification_summary">Zakáže tuto vývojářskou možnost při obnovování souborů APK a poté ji znovu povolí. Vyřeší chybu: INSTALL_FAILED_VERIFICATION_FAILURE.</string>
Expand Down Expand Up @@ -195,7 +192,6 @@
<string name="prefs_deviceprotecteddata_summary">Zálohuje a obnoví data umístěná v adresáři data/user_de</string>
<string name="prefs_numBackupRevisions">Počet revizí zálohy</string>
<string name="prefs_numBackupRevisions_summary">Nejstarší revize bude odstraněna po vytvoření nové zálohy, pokud bude počet překročen. Nastavte na nulu pro ponechání všech revizí.</string>
<string name="prefs_housekeepingmoment">Revize času čištění</string>
<string name="prefs_disableverification">Zakázat Ověřovat aplikace přes USB</string>
<string name="prefs_allowdowngrade_summary">Umožnit obnovení starší verze nainstalované aplikace.</string>
<string name="prefs_allowdowngrade">Povolit snížení verze</string>
Expand Down
4 changes: 0 additions & 4 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,6 @@
<string name="prefs_stopcont_summary">Nur für Fortgeschrittene: Das Aktivieren dieser Option kann helfen, wenn die App Dateien während des Sicherung ändert und die Sicherung fehlschlägt.</string>
<string name="prefs_stopcont">Beenden der App-Prozesse vor der Sicherung/Wiederherstellung erzwingen</string>
<string name="prefs_advanced">Erweiterte Einstellungen</string>
<string name="prefs_housekeepingmoment_summary">Legt fest, ob die älteste Revision vor oder nach der Erstellung einer neuen Sicherung gelöscht wird, um den von der Sicherung belegten Speicherplatz freizugeben.</string>
<string name="prefs_housekeepingmoment">Zeitpunkt des Löschens alter Revisionen</string>
<string name="prefs_housekeepingmoment_before">Vor der Sicherung</string>
<string name="prefs_housekeepingmoment_after">Nach der Sicherung</string>
<string name="radio_obbdata">OBB Daten</string>
<string name="radio_deviceprotecteddata">Geschützte Geräte-Daten</string>
<string name="radio_externaldata">Externe Daten</string>
Expand Down
4 changes: 0 additions & 4 deletions app/src/main/res/values-el/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,6 @@
<string name="prefs_stopcont_summary">Για εξειδικευμένους μόνο: Αυτό μπορεί να βοηθήσει, εάν η εφαρμογή μεταβάλλει αρχεία κατά τη δημιουργία αντιγράφου και η δημιουργία αντιγράφου αποτυγχάνει.</string>
<string name="prefs_stopcont">Αναγκαστικός-τερματισμός διεργασίας εφαρμογής πριν από δημιουργία αντιγράφου/επαναφορά</string>
<string name="prefs_advanced">Προηγμένες προτιμήσεις</string>
<string name="prefs_housekeepingmoment_summary">Ρυθμίζει εάν η παλαιότερη εκδοχή διαγράφεται πριν ή μετά τη δημιουργία ενός νέου αντιγράφου ώστε να ελευθερώσει το χώρο του δίσκου που χρησιμοποιείται από το αντίγραφο.</string>
<string name="prefs_housekeepingmoment">Χρόνος Καθαρισμού Εκδοχών</string>
<string name="prefs_housekeepingmoment_before">Πριν τη δημιουργία Αντιγράφου ασφαλείας</string>
<string name="prefs_housekeepingmoment_after">Μετά τη δημιουργία Αντιγράφου ασφαλείας</string>
<string name="radio_obbdata">Δεδομένα OBB</string>
<string name="radio_deviceprotecteddata">Προστατευμένα από τη Συσκευή Δεδομένα</string>
<string name="radio_externaldata">Εξωτερικά Δεδομένα</string>
Expand Down
4 changes: 0 additions & 4 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,8 @@
<string name="delete_all_backups">Borrar todos los respaldos</string>
<string name="prefs_stopcont_summary">Solo expertos: esto puede ayudar si la aplicación está cambiando archivos durante el respaldo y el respaldo falla.</string>
<string name="prefs_disableverification">Desactivar la verificación de aplicaciones por USB</string>
<string name="prefs_housekeepingmoment_summary">Configura si la revisión más antigua es eliminada antes o después de crear un nuevo respaldo para liberar espacio de disco usado por el respaldo.</string>
<string name="prefs_housekeepingmoment">Tiempo para la limpieza de revisiones</string>
<string name="prefs_numBackupRevisions_summary">La revisión más antigua será borrada tras la creación de un nuevo respaldo si el número es excedido. Déjalo en cero para mantener todas las revisiones.</string>
<string name="prefs_numBackupRevisions">Número de revisiones del respaldo</string>
<string name="prefs_housekeepingmoment_before">Antes del respaldo</string>
<string name="prefs_housekeepingmoment_after">Después del respaldo</string>
<string name="prefs_advanced">Preferencias avanzadas</string>
<string name="radio_obbdata">Datos OBB</string>
<string name="radio_deviceprotecteddata">Datos protegidos del dispositivo</string>
Expand Down
4 changes: 0 additions & 4 deletions app/src/main/res/values-et/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@
<string name="prefs_biometriclock">Biomeetrialukk</string>
<string name="prefs_stopcont_summary">Ainult ekspertidele: see võib aidata kui rakendus muudab faile varundamise ajal ning varundamine ebaõnnestub.</string>
<string name="prefs_disableverification_summary">Keelab APKide taastamisel selle arendusvaliku ning lubab hiljem uuesti. Parandab vea INSTALL_FAILED_VERIFICATION_FAILURE.</string>
<string name="prefs_housekeepingmoment_summary">Määrab, kas vanim varundus kustutatakse enne või pärast uue varunduse loomist, et vabastada varunduseks kasutatavat kettaruumi.</string>
<string name="fetching_action_list">Varundamiseks rakenduste nimekirja hankimine…</string>
<string name="msg_appkill_warning">Valitud rakendus(t)el palutakse töötamine lõpetada ning peale ülesande täitmist uuesti jätkata. Palun veendu, et kontrollid rakendusi peale ülesande täitmist ning väldi nende käivitamist protsessi toimimise ajal.</string>
<string name="intro_permission_storage_location">See rakendus vajab kohta, kus varundusi hoida. Rakendus võib vajada paar gigabaiti täisvarunduse jaoks ning teeb failisüsteemi palju päringuid. Pea seda meeles, kui valid võrgupõhise salvestuskoha.</string>
Expand All @@ -194,11 +193,8 @@
<string name="delete_all_backups">Kustuta kõik varundused</string>
<string name="help_legend">Legend:</string>
<string name="prefs_unset">Määramata</string>
<string name="prefs_housekeepingmoment">Varunduste tühjendusaeg</string>
<string name="prefs_numBackupRevisions_summary">Vanim varundus kustutatakse uue loomisel, kui see arv on ületatud. Sea väärtuseks null, et jätta kõik alles.</string>
<string name="prefs_numBackupRevisions">Varunduste arv</string>
<string name="prefs_housekeepingmoment_before">Enne varundust</string>
<string name="prefs_housekeepingmoment_after">Pärast varundust</string>
<string name="prefs_advanced">Täpsemad eelistused</string>
<string name="radio_obbdata">OBB andmed</string>
<string name="radio_deviceprotecteddata">Seadmes kaitstud andmed</string>
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values-fa/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@
<string name="prefs_theme">پوسته</string>
<string name="prefs_theme_light">روشن</string>
<string name="prefs_theme_dark">تیره</string>
<string name="prefs_housekeepingmoment_after">پس از پشتیبان‌گیری</string>
<string name="prefs_housekeepingmoment_before">پیش از پشتیبان‌گیری</string>
<string name="prefs_theme_system">پوسته سیستم</string>
<string name="prefs_languages">زبان</string>
<string name="prefs_language_system">پیشفرض سیستم</string>
Expand Down
Loading

0 comments on commit eb1d4c0

Please sign in to comment.