mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-11-07 17:36:07 +00:00
Add lock to chatlog file (#1488)
This commit is contained in:
parent
771a5b9e08
commit
4853871ea1
1 changed files with 13 additions and 10 deletions
|
|
@ -19,6 +19,7 @@ namespace MinecraftClient.ChatBots
|
|||
private bool savePrivate = true;
|
||||
private bool saveInternal = true;
|
||||
private string logfile;
|
||||
private object logfileLock = new object();
|
||||
|
||||
/// <summary>
|
||||
/// This bot saves the messages received in the specified file, with some filters and date/time tagging.
|
||||
|
|
@ -112,7 +113,8 @@ namespace MinecraftClient.ChatBots
|
|||
{
|
||||
if (dateandtime)
|
||||
tosave = GetTimestamp() + ' ' + tosave;
|
||||
|
||||
lock (logfileLock)
|
||||
{
|
||||
string directory = Path.GetDirectoryName(logfile);
|
||||
if (!String.IsNullOrEmpty(directory) && !Directory.Exists(directory))
|
||||
Directory.CreateDirectory(directory);
|
||||
|
|
@ -124,4 +126,5 @@ namespace MinecraftClient.ChatBots
|
|||
stream.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue