void BotDisconnected(object aSender, EventArgs <Packet> aEventArgs) { var download = _botDownloads.SingleOrDefault(c => c.Packet == aEventArgs.Value1); if (download != null) { download.Packet = null; download.OnDisconnected -= BotDisconnected; download.OnNotificationAdded -= AddNotification; _botDownloads.Remove(download); if (!AllowRunning) { return; } try { // if the connection never connected, there will be no file // and if we manually stopped the packet there will be file also // the missing size is negative?! if (download.File != null && download.File.MissingSize <= 0) { // do this here because the bothandler sets the file state FileActions.FinishFile(download.File); } } catch (Exception ex) { _log.Fatal("BotDisconnected()", ex); } try { IrcConnection connection = _connections.SingleOrDefault(c => c.Server == aEventArgs.Value1.Parent.Parent.Parent); if (connection != null) { connection.AddBotToQueue(aEventArgs.Value1.Parent, Settings.Default.CommandWaitTime); } } catch (Exception ex) { _log.Fatal("BotDisconnected() request", ex); } } }
void TryToRecoverOpenFiles() { foreach (XG.Model.Domain.File file in Files.All) { var info = new FileInfo(Settings.Default.TempPath + file.TmpName); // lets check if the file is still on the harddisk if (!info.Exists) { Log.Warn("TryToRecoverOpenFiles() " + info.FullName + " is missing "); Files.Remove(file); continue; } if (!file.Enabled) { // check if the real file and the part is actual the same if (file.CurrentSize != info.Length) { Log.Warn("TryToRecoverOpenFiles() size mismatch of " + file + " - db:" + file.CurrentSize + " real:" + info.Length); file.CurrentSize = info.Length; } // uhh, this is bad - close it and hope it works again if (file.Connected) { file.Connected = false; } file.Commit(); if (!file.Enabled && file.MissingSize == 0) { FileActions.FinishFile(file); } } } }