mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
Change backup file names
We use the application ID now to ensure uniqueness if the same folder is selected between different app versions/forks. This will make more sense once storage settings are unified to a single location. Also changes the file extension while we're at it so people stop accidentally ungzipping it. Co-Authored-By: arkon <4098258+arkon@users.noreply.github.com>
This commit is contained in:
parent
8f7a45e967
commit
cd550d545a
2 changed files with 5 additions and 3 deletions
|
@ -77,8 +77,7 @@ class BackupManager(context: Context) : AbstractBackupManager(context) {
|
|||
|
||||
// Delete older backups
|
||||
val numberOfBackups = numberOfBackups()
|
||||
val backupRegex = Regex("""tachiyomi_\d+-\d+-\d+_\d+-\d+.proto.gz""")
|
||||
dir.listFiles { _, filename -> backupRegex.matches(filename) }
|
||||
dir.listFiles { _, filename -> Backup.filenameRegex.matches(filename) }
|
||||
.orEmpty()
|
||||
.sortedByDescending { it.name }
|
||||
.drop(numberOfBackups - 1)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package eu.kanade.tachiyomi.data.backup.models
|
||||
|
||||
import eu.kanade.tachiyomi.BuildConfig
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.protobuf.ProtoNumber
|
||||
import java.text.SimpleDateFormat
|
||||
|
@ -15,9 +16,11 @@ data class Backup(
|
|||
@ProtoNumber(101) var backupSources: List<BackupSource> = emptyList(),
|
||||
) {
|
||||
companion object {
|
||||
val filenameRegex = """(${BuildConfig.APPLICATION_ID}|tachiyomi)?_\d+-\d+-\d+_\d+-\d+\.(tachibk|proto\.gz)""".toRegex()
|
||||
|
||||
fun getBackupFilename(): String {
|
||||
val date = SimpleDateFormat("yyyy-MM-dd_HH-mm", Locale.getDefault()).format(Date())
|
||||
return "tachiyomi_$date.proto.gz"
|
||||
return "${BuildConfig.APPLICATION_ID}_$date.tachibk"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue