2023-11-05 01:01:11 +00:00
|
|
|
import "pkg:/source/utils/misc.bs"
|
2023-11-15 16:30:10 +00:00
|
|
|
import "pkg:/source/utils/conditional.bs"
|
2023-09-23 21:06:36 +00:00
|
|
|
|
2023-11-16 03:19:23 +00:00
|
|
|
' @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"
|
2023-09-21 18:46:18 +00:00
|
|
|
|
|
|
|
' Run all necessary registry mirations on the "global" Jellyfin registry section
|
|
|
|
sub runGlobalMigrations()
|
2023-11-15 17:33:06 +00:00
|
|
|
appLastRunVersion = m.global.app.lastRunVersion
|
2023-09-21 18:46:18 +00:00
|
|
|
' Global registry migrations
|
2023-11-16 03:19:23 +00:00
|
|
|
if isValid(appLastRunVersion) and not versionChecker(appLastRunVersion, CLIENT_VERSION_REQUIRING_BASE_MIGRATION)
|
2023-11-16 23:19:41 +00:00
|
|
|
' last app version used < CLIENT_VERSION_REQUIRING_BASE_MIGRATION
|
2023-11-15 17:33:06 +00:00
|
|
|
m.wasMigrated = true
|
2023-11-16 03:19:23 +00:00
|
|
|
print `Running ${CLIENT_VERSION_REQUIRING_BASE_MIGRATION} global registry migrations`
|
2023-09-21 18:46:18 +00:00
|
|
|
' no longer saving raw password to registry
|
|
|
|
' auth token and username are now stored in user settings and not global settings
|
2023-09-23 21:06:36 +00:00
|
|
|
|
2023-11-22 21:47:01 +00:00
|
|
|
' enable remember me global setting for all devices whos last run version is < 2.0.0
|
|
|
|
' NOTE: remember me will be disabled for new installs
|
|
|
|
rememberMe = registry_read("global.rememberme", "Jellyfin")
|
|
|
|
if not isValid(rememberMe)
|
|
|
|
' don't overwrite users current setting (dev installs)
|
|
|
|
set_setting("global.rememberme", "true")
|
|
|
|
end if
|
2023-11-16 23:19:41 +00:00
|
|
|
' migrate saved credentials for "active_user" if found
|
2023-09-23 21:06:36 +00:00
|
|
|
savedUserId = get_setting("active_user")
|
|
|
|
if isValid(savedUserId)
|
|
|
|
savedUsername = get_setting("username")
|
|
|
|
if isValid(savedUsername)
|
|
|
|
registry_write("username", savedUsername, savedUserId)
|
|
|
|
end if
|
|
|
|
|
|
|
|
savedToken = get_setting("token")
|
|
|
|
if isValid(savedToken)
|
|
|
|
registry_write("token", savedToken, savedUserId)
|
|
|
|
end if
|
|
|
|
end if
|
2023-11-16 23:19:41 +00:00
|
|
|
' remove settings from global "jellyfin" registry block
|
2023-09-21 18:46:18 +00:00
|
|
|
unset_setting("port")
|
|
|
|
unset_setting("token")
|
|
|
|
unset_setting("username")
|
|
|
|
unset_setting("password")
|
2023-11-16 23:19:41 +00:00
|
|
|
' remove any saved credentials found in saved_servers assocArray
|
2023-09-21 18:46:18 +00:00
|
|
|
saved = get_setting("saved_servers")
|
|
|
|
if isValid(saved)
|
|
|
|
savedServers = ParseJson(saved)
|
|
|
|
if isValid(savedServers.serverList) and savedServers.serverList.Count() > 0
|
|
|
|
newServers = { serverList: [] }
|
|
|
|
for each item in savedServers.serverList
|
|
|
|
item.Delete("username")
|
|
|
|
item.Delete("password")
|
|
|
|
newServers.serverList.Push(item)
|
|
|
|
end for
|
|
|
|
set_setting("saved_servers", FormatJson(newServers))
|
|
|
|
end if
|
|
|
|
end if
|
2023-09-23 21:06:36 +00:00
|
|
|
end if
|
2023-09-21 18:46:18 +00:00
|
|
|
end sub
|
|
|
|
|
2023-11-15 16:30:10 +00:00
|
|
|
sub runRegistryUserMigrations()
|
2023-09-23 21:06:36 +00:00
|
|
|
regSections = getRegistrySections()
|
|
|
|
for each section in regSections
|
2023-10-20 02:13:11 +00:00
|
|
|
if LCase(section) <> "jellyfin"
|
2023-11-15 16:30:10 +00:00
|
|
|
reg = CreateObject("roRegistrySection", section)
|
|
|
|
if reg.exists("LastRunVersion")
|
2023-11-15 17:33:06 +00:00
|
|
|
hasUserVersion = true
|
2023-11-15 16:30:10 +00:00
|
|
|
lastRunVersion = reg.read("LastRunVersion")
|
|
|
|
else
|
2023-11-15 17:33:06 +00:00
|
|
|
hasUserVersion = false
|
2023-11-16 03:19:23 +00:00
|
|
|
' app versions < 2.0.0 didn't save LastRunVersion at the user level
|
2023-11-15 16:30:10 +00:00
|
|
|
' fall back to using the apps lastRunVersion
|
|
|
|
lastRunVersion = m.global.app.lastRunVersion
|
2023-12-13 03:20:11 +00:00
|
|
|
if isValid(lastRunVersion)
|
|
|
|
registry_write("LastRunVersion", lastRunVersion, section)
|
|
|
|
end if
|
2023-11-15 16:30:10 +00:00
|
|
|
end if
|
|
|
|
|
2023-11-16 03:19:23 +00:00
|
|
|
' BASE_MIGRATION
|
2023-12-13 03:20:11 +00:00
|
|
|
if isValid(lastRunVersion) and not versionChecker(lastRunVersion, CLIENT_VERSION_REQUIRING_BASE_MIGRATION)
|
2023-11-15 17:33:06 +00:00
|
|
|
m.wasMigrated = true
|
2023-11-16 03:19:23 +00:00
|
|
|
print `Running Registry Migration for ${CLIENT_VERSION_REQUIRING_BASE_MIGRATION} for userid: ${section}`
|
|
|
|
|
2023-11-25 13:25:31 +00:00
|
|
|
' If this is an existing user, set the useWebSectionArrangement setting to false
|
|
|
|
' This way the home view for upgrading users is not changed without them opting in
|
2023-11-26 20:48:50 +00:00
|
|
|
if not hasUserVersion
|
|
|
|
print "useWebSectionArrangement set to false"
|
2023-11-25 13:25:31 +00:00
|
|
|
registry_write("ui.home.useWebSectionArrangement", "false", section)
|
|
|
|
end if
|
|
|
|
|
2023-09-30 18:31:32 +00:00
|
|
|
' no longer saving password to registry
|
2023-09-23 21:06:36 +00:00
|
|
|
registry_delete("password", section)
|
2023-09-30 18:31:32 +00:00
|
|
|
' av1 playback no longer hidden behind user setting
|
|
|
|
registry_delete("playback.av1", section)
|
2023-09-23 21:06:36 +00:00
|
|
|
end if
|
|
|
|
end if
|
|
|
|
end for
|
2023-09-21 18:46:18 +00:00
|
|
|
end sub
|