Closed cquike closed 2 years ago
I seems to me that after removing the default server (which has key '0' in servers.json), the server1 with key '1' remains. The next server2 to be added will also be added as key '1', hence it overwrites existing configuration.
I think a possible solution could go along these lines:
--- a/resources/lib/servers_manager.py
+++ b/resources/lib/servers_manager.py
@@ -100,7 +100,7 @@ def addServer():
xbmc.log("AmpachePlugin::addServer" , xbmc.LOGDEBUG )
jsStorServer = json_storage.JsonStorage("servers.json")
serverData = jsStorServer.getData()
- stnum = str(len(list(serverData["servers"])))
+ stnum = str(max([int(i) for i in list(serverData["servers"])])+1)
username = ""
password = ""
apikey = ""
I have quickly tried that and seems to work.
I have to test it, cause i have never found this bug. So, you add a new server1, delete the default server , add another one and the new server1 is overwritten.
Correct. I think with that sequence you should be able to reproduce the bug. I didn't actually need to add "correct" servers, i.e., it is enough to add enter dummy entries for the URL, etc... That's enough to reproduce the bug.
ok, i think i have never figured out such situation, so i need some time to manage a solution ( or simply try yours )
with 65e2d6b71041e739b54ca292c7a0e5ad8fff83f1 i have rewritten the delete server logic, based on your code as a starting point.
Now when we remove a server, we replace it with the latest in the list ( to avoid a mess in the long run ) and when you delete all the servers, the plugin don't crashes. I should have covered all the possibile options.
Can you test the code , so i can close this issue?
Issue closed, in case of other problems it will be reopened.
I have an ampache server configured in the plugin. When I add a new server the old server disappears. This somehow worked at some point, so I think it happens under certain conditions: