Skip to content

Commit

Permalink
[fix]: removed old log dumps in database
Browse files Browse the repository at this point in the history
  • Loading branch information
F0x1d committed Dec 17, 2023
1 parent a2339f2 commit 24dbd61
Show file tree
Hide file tree
Showing 4 changed files with 212 additions and 6 deletions.
192 changes: 192 additions & 0 deletions app/schemas/com.f0x1d.logfox.database.AppDatabase/13.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
{
"formatVersion": 1,
"database": {
"version": 13,
"identityHash": "af5c43f71282bbd112ac34b19baec49e",
"entities": [
{
"tableName": "AppCrash",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`app_name` TEXT, `package_name` TEXT NOT NULL, `crash_type` INTEGER NOT NULL, `date_and_time` INTEGER NOT NULL, `log` TEXT NOT NULL, `log_dump_file` TEXT, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)",
"fields": [
{
"fieldPath": "appName",
"columnName": "app_name",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "packageName",
"columnName": "package_name",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "crashType",
"columnName": "crash_type",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "dateAndTime",
"columnName": "date_and_time",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "log",
"columnName": "log",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "logDumpFile",
"columnName": "log_dump_file",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"id"
]
},
"indices": [
{
"name": "index_AppCrash_date_and_time",
"unique": false,
"columnNames": [
"date_and_time"
],
"orders": [],
"createSql": "CREATE INDEX IF NOT EXISTS `index_AppCrash_date_and_time` ON `${TABLE_NAME}` (`date_and_time`)"
}
],
"foreignKeys": []
},
{
"tableName": "LogRecording",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`title` TEXT NOT NULL, `date_and_time` INTEGER NOT NULL, `file` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)",
"fields": [
{
"fieldPath": "title",
"columnName": "title",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "dateAndTime",
"columnName": "date_and_time",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "file",
"columnName": "file",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"id"
]
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "UserFilter",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`including` INTEGER NOT NULL, `allowed_levels` TEXT NOT NULL, `uid` TEXT, `pid` TEXT, `tid` TEXT, `package_name` TEXT, `tag` TEXT, `content` TEXT, `enabled` INTEGER NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)",
"fields": [
{
"fieldPath": "including",
"columnName": "including",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "allowedLevels",
"columnName": "allowed_levels",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "uid",
"columnName": "uid",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "pid",
"columnName": "pid",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "tid",
"columnName": "tid",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "packageName",
"columnName": "package_name",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "tag",
"columnName": "tag",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "content",
"columnName": "content",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "enabled",
"columnName": "enabled",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"id"
]
},
"indices": [],
"foreignKeys": []
}
],
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'af5c43f71282bbd112ac34b19baec49e')"
]
}
}
21 changes: 20 additions & 1 deletion app/src/main/java/com/f0x1d/logfox/database/AppDatabase.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.f0x1d.logfox.database

import androidx.room.AutoMigration
import androidx.room.Database
import androidx.room.DeleteColumn
import androidx.room.RoomDatabase
import androidx.room.TypeConverters
import androidx.room.migration.AutoMigrationSpec
import androidx.room.migration.Migration
import com.f0x1d.logfox.LogFoxApp
import com.f0x1d.logfox.R
Expand All @@ -15,7 +18,21 @@ import com.f0x1d.logfox.database.entity.LogRecordingDao
import com.f0x1d.logfox.database.entity.UserFilter
import com.f0x1d.logfox.database.entity.UserFilterDao

@Database(entities = [AppCrash::class, LogRecording::class, UserFilter::class], version = 12)
@Database(
entities = [
AppCrash::class,
LogRecording::class,
UserFilter::class
],
version = 13,
autoMigrations = [
AutoMigration(
from = 12,
to = 13,
spec = AppDatabase.Companion.AutoMigration12_13::class
)
]
)
@TypeConverters(CrashTypeConverter::class, AllowedLevelsConverter::class)
abstract class AppDatabase: RoomDatabase() {

Expand Down Expand Up @@ -54,6 +71,8 @@ abstract class AppDatabase: RoomDatabase() {
val MIGRATION_11_12 = Migration(11, 12) {
it.execSQL("CREATE INDEX index_AppCrash_date_and_time ON AppCrash(date_and_time)")
}
@DeleteColumn(tableName = "AppCrash", columnName = "log_dump")
class AutoMigration12_13: AutoMigrationSpec
}

abstract fun appCrashDao(): AppCrashDao
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ data class AppCrash(
@ColumnInfo(name = "crash_type") val crashType: CrashType,
@ColumnInfo(name = "date_and_time", index = true) val dateAndTime: Long,
@ColumnInfo(name = "log") val log: String,
@Deprecated("Use logDumpFile") @ColumnInfo(name = "log_dump") val logDump: String? = null,
@ColumnInfo(name = "log_dump_file") val logDumpFile: String? = null,
@PrimaryKey(autoGenerate = true) val id: Long = 0
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ class CrashDetailsViewModel @Inject constructor(

putZipEntry("crash.log", appCrash.log.encodeToByteArray())

if (!appCrash.logDump.isNullOrEmpty()) putZipEntry(
"dump.log",
appCrash.logDump.encodeToByteArray()
)
if (appCrash.logDumpFile != null) putZipEntry(
"dump.log",
File(appCrash.logDumpFile)
Expand Down

0 comments on commit 24dbd61

Please sign in to comment.