use constant for migration verison string

This commit is contained in:
Charles Ewert 2023-11-15 22:19:23 -05:00
parent 4133154443
commit 52ea035a2c

View File

@ -1,16 +1,18 @@
import "pkg:/source/utils/misc.bs" import "pkg:/source/utils/misc.bs"
import "pkg:/source/utils/conditional.bs" import "pkg:/source/utils/conditional.bs"
' Functions that update the registry based on the last run version and the currently running version ' @fileoverview Functions that update the registry based on the last run version and the currently running version
const CLIENT_VERSION_REQUIRING_BASE_MIGRATION = "2.0.0"
' Run all necessary registry mirations on the "global" Jellyfin registry section ' Run all necessary registry mirations on the "global" Jellyfin registry section
sub runGlobalMigrations() sub runGlobalMigrations()
appLastRunVersion = m.global.app.lastRunVersion appLastRunVersion = m.global.app.lastRunVersion
' Global registry migrations ' Global registry migrations
if isValid(appLastRunVersion) and not versionChecker(appLastRunVersion, "2.0.0") if isValid(appLastRunVersion) and not versionChecker(appLastRunVersion, CLIENT_VERSION_REQUIRING_BASE_MIGRATION)
m.wasMigrated = true m.wasMigrated = true
' last app version used was less than 2.0.0 ' last app version used was less than CLIENT_VERSION_REQUIRING_BASE_MIGRATION
print "Running 2.0.0 global registry migrations" print `Running ${CLIENT_VERSION_REQUIRING_BASE_MIGRATION} global registry migrations`
' no longer saving raw password to registry ' no longer saving raw password to registry
' auth token and username are now stored in user settings and not global settings ' auth token and username are now stored in user settings and not global settings
@ -59,19 +61,17 @@ sub runRegistryUserMigrations()
lastRunVersion = reg.read("LastRunVersion") lastRunVersion = reg.read("LastRunVersion")
else else
hasUserVersion = false hasUserVersion = false
' app versions < 2.0.0 didn't save LastRunVersion at the user level
' fall back to using the apps lastRunVersion ' fall back to using the apps lastRunVersion
' NOTE: app versions < 2.0.0 didn't save this at the user level
lastRunVersion = m.global.app.lastRunVersion lastRunVersion = m.global.app.lastRunVersion
registry_write("LastRunVersion", m.global.app.version, section) registry_write("LastRunVersion", m.global.app.version, section)
end if end if
' 2.0.0 ' BASE_MIGRATION
if not versionChecker(lastRunVersion, "2.0.0") if not versionChecker(lastRunVersion, CLIENT_VERSION_REQUIRING_BASE_MIGRATION)
m.wasMigrated = true m.wasMigrated = true
print "Running Registry Migration for 2.0.0 for userid: " + section print `Running Registry Migration for ${CLIENT_VERSION_REQUIRING_BASE_MIGRATION} for userid: ${section}`
' now saving LastRunVersion per user in addition to globally so that we can run user specific registry migrations
' duplicate LastRunVersion to all user settings in the registry so that we can run user specific migrations
'
' no longer saving password to registry ' no longer saving password to registry
registry_delete("password", section) registry_delete("password", section)
' av1 playback no longer hidden behind user setting ' av1 playback no longer hidden behind user setting