-
-
Notifications
You must be signed in to change notification settings - Fork 33
Update repo tracking system - respect repo #125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
netmindz
wants to merge
12
commits into
Moustachauve:main
Choose a base branch
from
netmindz:copilot/update-repo-tracking-system
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
b7e70ff
Initial plan
Copilot c526ea0
Add multi-repository support for WLED updates
Copilot c5a901d
Fix code issues found in review
Copilot 1129f0c
Fix incorrect version reference for repo field
Copilot aef5a63
Restore UpdateSourceRegistry as fallback for missing repo field
Copilot b89efb4
Fix checkForUpdates to refresh all discovered device repositories
Copilot cd0ce47
Fix checkForUpdates to only refresh selected device's repository
Copilot a2d0b82
Update app/src/main/java/ca/cgagnier/wlednativeandroid/service/update…
netmindz 24258a2
Update app/src/main/java/ca/cgagnier/wlednativeandroid/ui/homeScreen/…
netmindz f04e26b
Centralize DEFAULT_REPO constant to avoid duplication
Copilot 48a299b
Fix data loss in database migration 9→10
Copilot a026381
Fix manual ReleaseService instantiation in DeviceEditViewModel
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
app/src/main/java/ca/cgagnier/wlednativeandroid/repository/migrations/DbMigration10To11.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package ca.cgagnier.wlednativeandroid.repository.migrations | ||
|
|
||
| import androidx.room.DeleteTable | ||
| import androidx.room.migration.AutoMigrationSpec | ||
|
|
||
| /** | ||
| * Migration from 10->11 removes the old Version and Asset tables after data has been migrated | ||
| * to the new schema with repository tracking support. | ||
| */ | ||
| @DeleteTable(tableName = "Version_old") | ||
| @DeleteTable(tableName = "Asset_old") | ||
| class DbMigration10To11 : AutoMigrationSpec |
105 changes: 105 additions & 0 deletions
105
app/src/main/java/ca/cgagnier/wlednativeandroid/repository/migrations/DbMigration9To10.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| package ca.cgagnier.wlednativeandroid.repository.migrations | ||
|
|
||
| import android.util.Log | ||
| import androidx.room.RenameTable | ||
| import androidx.room.migration.AutoMigrationSpec | ||
| import androidx.sqlite.db.SupportSQLiteDatabase | ||
|
|
||
| private const val TAG = "DbMigration9To10" | ||
|
|
||
| /** | ||
| * Migration from 9->10 adds repository information to Version and Asset tables | ||
| * to support tracking releases from multiple WLED repositories/forks. | ||
| * | ||
| * We rename the old tables, create new ones with repository field, | ||
| * copy existing data with default repository "wled/WLED", then drop the old tables. | ||
| */ | ||
| @RenameTable(fromTableName = "Version", toTableName = "Version_old") | ||
| @RenameTable(fromTableName = "Asset", toTableName = "Asset_old") | ||
| class DbMigration9To10 : AutoMigrationSpec { | ||
| override fun onPostMigrate(db: SupportSQLiteDatabase) { | ||
| Log.i(TAG, "onPostMigrate starting - migrating Version and Asset data") | ||
|
|
||
| // Migrate Version table | ||
| val originalVersionCountCursor = db.query("SELECT COUNT(*) FROM Version_old") | ||
| var originalVersionCount = 0 | ||
| if (originalVersionCountCursor.moveToFirst()) { | ||
| originalVersionCount = originalVersionCountCursor.getInt(0) | ||
| } | ||
| originalVersionCountCursor.close() | ||
| Log.i(TAG, "Total versions in old 'Version' table: $originalVersionCount") | ||
|
|
||
| // Copy data from Version_old to Version with default repository | ||
| db.execSQL( | ||
| """ | ||
| INSERT OR IGNORE INTO Version ( | ||
| tagName, | ||
| repository, | ||
| name, | ||
| description, | ||
| isPrerelease, | ||
| publishedDate, | ||
| htmlUrl | ||
| ) | ||
| SELECT | ||
| tagName, | ||
| 'wled/WLED' AS repository, | ||
| name, | ||
| description, | ||
| isPrerelease, | ||
| publishedDate, | ||
| htmlUrl | ||
| FROM Version_old | ||
| """.trimIndent() | ||
| ) | ||
|
|
||
| val migratedVersionCountCursor = db.query("SELECT COUNT(*) FROM Version") | ||
| var migratedVersionCount = 0 | ||
| if (migratedVersionCountCursor.moveToFirst()) { | ||
| migratedVersionCount = migratedVersionCountCursor.getInt(0) | ||
| } | ||
| migratedVersionCountCursor.close() | ||
| Log.i(TAG, "Versions migrated to new table: $migratedVersionCount") | ||
|
|
||
| // Migrate Asset table | ||
| val originalAssetCountCursor = db.query("SELECT COUNT(*) FROM Asset_old") | ||
| var originalAssetCount = 0 | ||
| if (originalAssetCountCursor.moveToFirst()) { | ||
| originalAssetCount = originalAssetCountCursor.getInt(0) | ||
| } | ||
| originalAssetCountCursor.close() | ||
| Log.i(TAG, "Total assets in old 'Asset' table: $originalAssetCount") | ||
|
|
||
| // Copy data from Asset_old to Asset with default repository | ||
| db.execSQL( | ||
| """ | ||
| INSERT OR IGNORE INTO Asset ( | ||
| versionTagName, | ||
| repository, | ||
| name, | ||
| size, | ||
| downloadUrl, | ||
| assetId | ||
| ) | ||
| SELECT | ||
| versionTagName, | ||
| 'wled/WLED' AS repository, | ||
| name, | ||
| size, | ||
| downloadUrl, | ||
| assetId | ||
| FROM Asset_old | ||
| """.trimIndent() | ||
| ) | ||
|
|
||
| val migratedAssetCountCursor = db.query("SELECT COUNT(*) FROM Asset") | ||
| var migratedAssetCount = 0 | ||
| if (migratedAssetCountCursor.moveToFirst()) { | ||
| migratedAssetCount = migratedAssetCountCursor.getInt(0) | ||
| } | ||
| migratedAssetCountCursor.close() | ||
| Log.i(TAG, "Assets migrated to new table: $migratedAssetCount") | ||
|
|
||
| Log.i(TAG, "onPostMigrate done! Migration is complete.") | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current auto-migration strategy for versions 9 to 11 will result in data loss for existing users. The
AutoMigrationfrom 9 to 10 renames theVersionandAssettables, and Room then creates new, empty tables. The data from the old tables is never copied over before they are dropped in the migration from 10 to 11. This means all cached release information will be lost upon app update.To fix this, you should use a manual
Migrationinstead ofAutoMigrationfor the 9 to 10 transition. In a manual migration, you can use SQL to create new tables, copy data from the old tables to the new ones (while populating the newrepositorycolumn with a default value), and then drop the old tables.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this fixed by 48a299b ?