db: mark profile store as deprecated

db
Harvey Tindall 1 year ago
parent a735e4ff29
commit 3bb9272f06
No known key found for this signature in database
GPG Key ID: BBC65952848FB1A2

@ -238,7 +238,7 @@ func migrateToBadger(app *appContext) {
} }
app.storage.loadProfiles() app.storage.loadProfiles()
for k, v := range app.storage.profiles { for k, v := range app.storage.deprecatedProfiles {
app.storage.SetProfileKey(k, v) app.storage.SetProfileKey(k, v)
} }
} }

@ -34,8 +34,7 @@ type Storage struct {
invite_path, emails_path, policy_path, configuration_path, displayprefs_path, ombi_path, profiles_path, customEmails_path, users_path, telegram_path, discord_path, matrix_path, announcements_path, matrix_sql_path, userPage_path string invite_path, emails_path, policy_path, configuration_path, displayprefs_path, ombi_path, profiles_path, customEmails_path, users_path, telegram_path, discord_path, matrix_path, announcements_path, matrix_sql_path, userPage_path string
deprecatedUserExpiries map[string]time.Time // Map of Jellyfin User IDs to their expiry times. deprecatedUserExpiries map[string]time.Time // Map of Jellyfin User IDs to their expiry times.
deprecatedInvites Invites deprecatedInvites Invites
profiles map[string]Profile deprecatedProfiles map[string]Profile
defaultProfile string
displayprefs, ombi_template map[string]interface{} displayprefs, ombi_template map[string]interface{}
deprecatedEmails emailStore // Map of Jellyfin User IDs to Email addresses. deprecatedEmails emailStore // Map of Jellyfin User IDs to Email addresses.
deprecatedTelegram telegramStore // Map of Jellyfin User IDs to telegram users. deprecatedTelegram telegramStore // Map of Jellyfin User IDs to telegram users.
@ -1254,11 +1253,11 @@ func (st *Storage) storeAnnouncements() error {
} }
func (st *Storage) loadProfiles() error { func (st *Storage) loadProfiles() error {
err := loadJSON(st.profiles_path, &st.profiles) err := loadJSON(st.profiles_path, &st.deprecatedProfiles)
for name, profile := range st.profiles { for name, profile := range st.deprecatedProfiles {
if profile.Default { // if profile.Default {
st.defaultProfile = name // st.defaultProfile = name
} // }
change := false change := false
if profile.Policy.IsAdministrator != profile.Admin { if profile.Policy.IsAdministrator != profile.Admin {
change = true change = true
@ -1278,19 +1277,19 @@ func (st *Storage) loadProfiles() error {
change = true change = true
} }
if change { if change {
st.profiles[name] = profile st.deprecatedProfiles[name] = profile
}
}
if st.defaultProfile == "" {
for n := range st.profiles {
st.defaultProfile = n
} }
} }
// if st.defaultProfile == "" {
// for n := range st.deprecatedProfiles {
// st.defaultProfile = n
// }
// }
return err return err
} }
func (st *Storage) storeProfiles() error { func (st *Storage) storeProfiles() error {
return storeJSON(st.profiles_path, st.profiles) return storeJSON(st.profiles_path, st.deprecatedProfiles)
} }
func (st *Storage) migrateToProfile() error { func (st *Storage) migrateToProfile() error {
@ -1298,7 +1297,7 @@ func (st *Storage) migrateToProfile() error {
st.loadConfiguration() st.loadConfiguration()
st.loadDisplayprefs() st.loadDisplayprefs()
st.loadProfiles() st.loadProfiles()
st.profiles["Default"] = Profile{ st.deprecatedProfiles["Default"] = Profile{
Policy: st.policy, Policy: st.policy,
Configuration: st.configuration, Configuration: st.configuration,
Displayprefs: st.displayprefs, Displayprefs: st.displayprefs,

Loading…
Cancel
Save