From 3bb9272f0679d93157a702299c080caf63b02173 Mon Sep 17 00:00:00 2001 From: Harvey Tindall Date: Sat, 24 Jun 2023 21:31:22 +0100 Subject: [PATCH] db: mark profile store as deprecated --- migrations.go | 2 +- storage.go | 29 ++++++++++++++--------------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/migrations.go b/migrations.go index 8d73e05..6e9806b 100644 --- a/migrations.go +++ b/migrations.go @@ -238,7 +238,7 @@ func migrateToBadger(app *appContext) { } app.storage.loadProfiles() - for k, v := range app.storage.profiles { + for k, v := range app.storage.deprecatedProfiles { app.storage.SetProfileKey(k, v) } } diff --git a/storage.go b/storage.go index dbe11e4..2fc6cf9 100644 --- a/storage.go +++ b/storage.go @@ -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 deprecatedUserExpiries map[string]time.Time // Map of Jellyfin User IDs to their expiry times. deprecatedInvites Invites - profiles map[string]Profile - defaultProfile string + deprecatedProfiles map[string]Profile displayprefs, ombi_template map[string]interface{} deprecatedEmails emailStore // Map of Jellyfin User IDs to Email addresses. deprecatedTelegram telegramStore // Map of Jellyfin User IDs to telegram users. @@ -1254,11 +1253,11 @@ func (st *Storage) storeAnnouncements() error { } func (st *Storage) loadProfiles() error { - err := loadJSON(st.profiles_path, &st.profiles) - for name, profile := range st.profiles { - if profile.Default { - st.defaultProfile = name - } + err := loadJSON(st.profiles_path, &st.deprecatedProfiles) + for name, profile := range st.deprecatedProfiles { + // if profile.Default { + // st.defaultProfile = name + // } change := false if profile.Policy.IsAdministrator != profile.Admin { change = true @@ -1278,19 +1277,19 @@ func (st *Storage) loadProfiles() error { change = true } if change { - st.profiles[name] = profile - } - } - if st.defaultProfile == "" { - for n := range st.profiles { - st.defaultProfile = n + st.deprecatedProfiles[name] = profile } } + // if st.defaultProfile == "" { + // for n := range st.deprecatedProfiles { + // st.defaultProfile = n + // } + // } return err } func (st *Storage) storeProfiles() error { - return storeJSON(st.profiles_path, st.profiles) + return storeJSON(st.profiles_path, st.deprecatedProfiles) } func (st *Storage) migrateToProfile() error { @@ -1298,7 +1297,7 @@ func (st *Storage) migrateToProfile() error { st.loadConfiguration() st.loadDisplayprefs() st.loadProfiles() - st.profiles["Default"] = Profile{ + st.deprecatedProfiles["Default"] = Profile{ Policy: st.policy, Configuration: st.configuration, Displayprefs: st.displayprefs,