Skip to content

Commit

Permalink
v5.10.x Fix issue #134; libraries no longer showing multiple times wh…
Browse files Browse the repository at this point in the history
…en running the config updater
  • Loading branch information
terrelsa13 committed Jan 3, 2025
1 parent 5eaa0c9 commit 07d1385
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 3 deletions.
19 changes: 18 additions & 1 deletion mumc_modules/mumc_builder_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,26 @@ def add_libraries_to_existing_users(the_dict):
the_dict['all_users_dict'][the_dict['prev_users_dict'].index(existing_user)][the_dict['opposing_listing_type']].append(the_dict['all_libraries_list'][all_lib_id_pos])
else:
for existing_lib_id in existing_lib_id_list:
exisiting_lib_id_index=existing_lib_id_list.index(existing_lib_id)
for all_lib_pos in range(len(the_dict['all_library_ids_list'])):
if (existing_lib_id == the_dict['all_library_ids_list'][all_lib_pos]):
if (not (the_dict['all_libraries_list'][all_lib_pos] in existing_lib_info_list)):
#remove "lib_enabled" before comparison
#"lib_enabled" is expected to be manually changed in the config and therefore should be ignored for the comparison
all_libraries_list_lib_enabled=the_dict['all_libraries_list'][all_lib_pos].pop('lib_enabled',None)
existing_lib_info_list_lib_enabled=existing_lib_info_list[exisiting_lib_id_index].pop('lib_enabled',None)

libraries_match=True
if (not (the_dict['all_libraries_list'][all_lib_pos] == existing_lib_info_list[exisiting_lib_id_index])):
libraries_match=False

#re-add "lib_enabled" after comparison
if (not (all_libraries_list_lib_enabled == None)):
the_dict['all_libraries_list'][all_lib_pos]['lib_enabled']=all_libraries_list_lib_enabled
if (not (existing_lib_info_list_lib_enabled == None)):
existing_lib_info_list[exisiting_lib_id_index]['lib_enabled']=existing_lib_info_list_lib_enabled

#if libraries do not match; add the "new" library for this user
if (not (libraries_match)):
the_dict['all_users_dict'][the_dict['prev_users_dict'].index(existing_user)][the_dict['opposing_listing_type']].append(the_dict['all_libraries_list'][all_lib_pos])
existing_lib_info_list.append(the_dict['all_libraries_list'][all_lib_pos])
existing_lib_id_list.append(the_dict['all_library_ids_list'][all_lib_pos])
Expand Down
53 changes: 52 additions & 1 deletion mumc_modules/mumc_config_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,56 @@
from mumc_modules.mumc_compare_items import keys_exist,keys_exist_return_value


def userLib_configurationUpdater(the_dict):

for userInfo in the_dict['admin_settings']['users']:
whitelist_libId_List=[]
blacklist_libId_List=[]
whitelist_pos_List=[]
blacklist_pos_List=[]
userIndex = the_dict['admin_settings']['users'].index(userInfo)
for libInfo in the_dict['admin_settings']['users'][userIndex]['whitelist']:
libIndex=the_dict['admin_settings']['users'][userIndex]['whitelist'].index(libInfo)
whitelist_libId_List.append(the_dict['admin_settings']['users'][userIndex]['whitelist'][libIndex]['lib_id'])
for libInfo in the_dict['admin_settings']['users'][userIndex]['blacklist']:
libIndex=the_dict['admin_settings']['users'][userIndex]['blacklist'].index(libInfo)
blacklist_libId_List.append(the_dict['admin_settings']['users'][userIndex]['blacklist'][libIndex]['lib_id'])

whitelist_libId_List.reverse()
for libInfo in whitelist_libId_List:
libIndex=whitelist_libId_List.index(libInfo)
if (whitelist_libId_List.count(whitelist_libId_List[libIndex]) > 1):
whitelist_libId_List[libIndex]=None
whitelist_libId_List.reverse()

blacklist_libId_List.reverse()
for libInfo in blacklist_libId_List:
libIndex=blacklist_libId_List.index(libInfo)
if (blacklist_libId_List.count(blacklist_libId_List[libIndex]) > 1):
blacklist_libId_List[libIndex]=None
blacklist_libId_List.reverse()

for libId in whitelist_libId_List:
if (libId == None):
libIndex=whitelist_libId_List.index(libId)
whitelist_pos_List.append(libIndex)
whitelist_libId_List[libIndex]=0

for libId in blacklist_libId_List:
if (libId == None):
libIndex=blacklist_libId_List.index(libId)
blacklist_pos_List.append(libIndex)
blacklist_libId_List[libIndex]=0

for libIndex in reversed(whitelist_pos_List):
the_dict['admin_settings']['users'][userIndex]['whitelist'].pop(libIndex)

for libIndex in reversed(blacklist_pos_List):
the_dict['admin_settings']['users'][userIndex]['blacklist'].pop(libIndex)

return the_dict['admin_settings']['users']


def yaml_configurationUpdater(the_dict,orig_dict={}):
config_data={}

Expand Down Expand Up @@ -85,7 +135,8 @@ def yaml_configurationUpdater(the_dict,orig_dict={}):
except:
pass
config_data['admin_settings']['server']=orig_dict['admin_settings']['server']
config_data['admin_settings']['users']=the_dict['admin_settings']['users']

config_data['admin_settings']['users']=userLib_configurationUpdater(the_dict)

try:
#check if radarr enabled key existed
Expand Down
2 changes: 1 addition & 1 deletion mumc_modules/mumc_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#Get the current script version
def get_script_version():
return '5.10.0-beta'
return '5.10.1-beta'


#Get the min config version
Expand Down

0 comments on commit 07d1385

Please sign in to comment.