Jessecar96 / SteamBot

Automated bot software for interacting with Steam Trade
http://scrap.tf
MIT License
1.33k stars 910 forks source link

IO exception when multiple bots have the same log file name. #74

Closed cwhelchel closed 11 years ago

cwhelchel commented 11 years ago

Found this out the hard way by copy-pasting configuration items in settings.json where logFile was the same value for each bot.

Also steam guard was on for the bot accounts and it was prompting for the code when this happened but I'm not sure if that's related.

teliosdev commented 11 years ago

Can I see the exception?

cwhelchel commented 11 years ago

It was on the lines of "System.IO.IOException file is being used by another process...". I can't provide a stack trace or anything like that until later today.

The work-around is to not configure the bot to use the same file name for each bots' log files. The fix is to make sure they are never configured the same by checking in code.

cwhelchel commented 11 years ago

From the log file for the program not the bots (syslog.log):

[(System) 06/11/2012 20:16:43] ERROR: Error With Bot: System.IO.IOException: The process cannot access the file 'C:\Users\cainan\Documents\GitHub\SteamBot\SteamBot\bin\Debug\bot1.log' because it is being used by another process.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.StreamWriter.CreateFile(String path, Boolean append)
   at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize)
   at System.IO.StreamWriter..ctor(String path, Boolean append)
   at System.IO.File.AppendText(String path)
   at SteamBot.Log..ctor(String logFile, String botName, LogLevel output) in C:\Users\cainan\Documents\GitHub\SteamBot\SteamBot\Log.cs:line 31
   at SteamBot.Bot..ctor(BotInfo config, String apiKey, UserHandlerCreator handlerCreator, Boolean debug) in C:\Users\cainan\Documents\GitHub\SteamBot\SteamBot\Bot.cs:line 101
   at SteamBot.Program.<>c__DisplayClass5.<Main>b__0() in C:\Users\cainan\Documents\GitHub\SteamBot\SteamBot\Program.cs:line 26
teliosdev commented 11 years ago

Is that really a problem with the bot? That seems more of a common sense error on the user's side...

cwhelchel commented 11 years ago

Oh yeah. It truly is common sense. As soon as I saw it I knew exactly what the problem was.

It just depends on how fancy we want to get with validating the user's settings file. I wanted to make sure that the issue was at least logged here.