From 810440e7bad589b9ea7d97ed01c70feae3d8ebae Mon Sep 17 00:00:00 2001 From: HarpyWar Date: Mon, 9 Apr 2018 23:07:46 +0300 Subject: [PATCH] Temporary fixes: - fix backup snapshot when output is created (sometimes getRegistration() throws exception for SuperUser) - fix restore snapshot (registerUser() throws exception for user names with special characters) --- Murmur/VirtualServer.cs | 18 +++++++++++++++--- Murmur/VirtualServerKeeper.cs | 20 +++++++++++++++----- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/Murmur/VirtualServer.cs b/Murmur/VirtualServer.cs index 06ba3ec..9bab1aa 100644 --- a/Murmur/VirtualServer.cs +++ b/Murmur/VirtualServer.cs @@ -884,11 +884,23 @@ internal static VirtualServerEntity.Channel getChannel(Channel c) // clear _entity.Users.Clear(); + var users = _server.getRegisteredUsers(filter); + // add - foreach (var u in _server.getRegisteredUsers(filter)) + foreach (var u in users) { - // insert to _entity.Users is in GetUser method - GetUser(u.Key, getInfo, getTexture, cache); // cache = always false + try + { + // insert to _entity.Users is in GetUser method + GetUser(u.Key, getInfo, getTexture, cache); // cache = always false + } + catch + { + // UNDONE: error reporting - bad user, mostly "SuperUser" (sometimes it may throws on _server.getRegistration(userId); +#if DEBUG + Console.WriteLine("[ERROR] bad user " + u.Value); +#endif + } } } return _entity.Users; diff --git a/Murmur/VirtualServerKeeper.cs b/Murmur/VirtualServerKeeper.cs index a08b8cb..4a340b7 100644 --- a/Murmur/VirtualServerKeeper.cs +++ b/Murmur/VirtualServerKeeper.cs @@ -161,14 +161,24 @@ private bool _restoreEntity(VirtualServerEntity entity) // remember old id, because after add user it will be updated to the new var old_uid = u.Value.Id; - // register new user and update object Id - u.Value.Id = server.RegisterUser(u.Value); + try + { + // register new user and update object Id + u.Value.Id = server.RegisterUser(u.Value); - // map oldid <-> newid - newUserIds.Add(old_uid, u.Value.Id); + // map oldid <-> newid + newUserIds.Add(old_uid, u.Value.Id); #if DEBUG - Console.WriteLine("[{0}][add] user #{1}", server.Id, u.Key); + Console.WriteLine("[{0}][add] user #{1}", server.Id, u.Key); #endif + } + catch + { + // UNDONE: user names with special characters (like ★) throw exception +#if DEBUG + Console.WriteLine("[ERROR] bad username " + u.Value.Info[VirtualServerEntity.User.UserInfo.UserName].ToString()); +#endif + } }