|
|
@ -31,14 +31,13 @@ object Backup { |
|
|
|
fun autoBack(context: Context) { |
|
|
|
fun autoBack(context: Context) { |
|
|
|
val lastBackup = context.getPrefLong(PreferKey.lastBackup) |
|
|
|
val lastBackup = context.getPrefLong(PreferKey.lastBackup) |
|
|
|
if (lastBackup + TimeUnit.DAYS.toMillis(1) < System.currentTimeMillis()) { |
|
|
|
if (lastBackup + TimeUnit.DAYS.toMillis(1) < System.currentTimeMillis()) { |
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Coroutine.async { |
|
|
|
Coroutine.async { |
|
|
|
context.getPrefString(PreferKey.backupPath)?.let { |
|
|
|
context.getPrefString(PreferKey.backupPath)?.let { |
|
|
|
backup(context, it, true) |
|
|
|
backup(context, it, true) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
suspend fun backup(context: Context, path: String, isAuto: Boolean = false) { |
|
|
|
suspend fun backup(context: Context, path: String, isAuto: Boolean = false) { |
|
|
|
context.putPrefLong(PreferKey.lastBackup, System.currentTimeMillis()) |
|
|
|
context.putPrefLong(PreferKey.lastBackup, System.currentTimeMillis()) |
|
|
|