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-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-11-15 17:33:06 +00:00
|
|
|
registry_write("LastRunVersion", m.global.app.version, section)
|
2023-11-15 16:30:10 +00:00
|
|
|
end if
|
|
|
|
|
2023-11-16 03:19:23 +00:00
|
|
|
' BASE_MIGRATION
|
|
|
|
if 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-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
|
2023-11-15 17:33:06 +00:00
|
|
|
|
|
|
|
' update lastRunVersion if needed
|
|
|
|
if hasUserVersion and lastRunVersion <> m.global.app.version
|
|
|
|
registry_write("LastRunVersion", m.global.app.version, section)
|
|
|
|
end if
|
2023-09-23 21:06:36 +00:00
|
|
|
end if
|
|
|
|
end for
|
2023-09-21 18:46:18 +00:00
|
|
|
end sub
|