Skip to content

Commit

Permalink
Delete old backup files
Browse files Browse the repository at this point in the history
  • Loading branch information
greenart7c3 committed Nov 4, 2024
1 parent 1da4682 commit cdc8525
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,16 @@ class WebSocketServerService : Service() {
val lastModifiedTime = folder.lastModified()
val currentTime = System.currentTimeMillis()
val twentyFourHoursAgo = currentTime - (24 * 60 * 60 * 1000)
val fiveDaysAgo = currentTime - (5 * 24 * 60 * 60 * 1000)

if (lastModifiedTime < twentyFourHoursAgo) {
Log.d(Citrine.TAG, "Deleting old backups")
folder.listFiles().forEach { file ->
if (file.lastModified() < fiveDaysAgo) {
file.delete()
}
}

Log.d(Citrine.TAG, "Backing up database")
ExportDatabaseUtils.exportDatabase(
database,
Expand Down

0 comments on commit cdc8525

Please sign in to comment.