Skip to content

Commit

Permalink
Temporary fixes:
Browse files Browse the repository at this point in the history
- 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)
  • Loading branch information
HarpyWar committed Apr 9, 2018
1 parent f58514e commit 810440e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
18 changes: 15 additions & 3 deletions Murmur/VirtualServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 15 additions & 5 deletions Murmur/VirtualServerKeeper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}


Expand Down

0 comments on commit 810440e

Please sign in to comment.