Small changes for later
This commit is contained in:
@ -45,7 +45,7 @@ namespace CoopClient
|
|||||||
|
|
||||||
lock (_streams)
|
lock (_streams)
|
||||||
{
|
{
|
||||||
_streams.Add(id, new FileStream($"{downloadFolder}\\{name}", FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite));
|
_streams.Add(id, new FileStream($"{downloadFolder}\\{name}", FileMode.CreateNew, FileAccess.Write, FileShare.ReadWrite));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,10 +87,11 @@ namespace CoopClient
|
|||||||
|
|
||||||
lock (_streams)
|
lock (_streams)
|
||||||
{
|
{
|
||||||
FileStream fs = _streams.ContainsKey(id) ? _streams[id] : null;
|
FileStream fs = _streams.FirstOrDefault(x => x.Key == id).Value;
|
||||||
if (fs == null)
|
if (fs == null)
|
||||||
{
|
{
|
||||||
throw new System.Exception($"Stream for file {id} doesn't found!");
|
Logger.Write($"Stream for file {id} not found!", Logger.LogLevel.Server);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.Write(data, 0, data.Length);
|
fs.Write(data, 0, data.Length);
|
||||||
@ -100,7 +101,8 @@ namespace CoopClient
|
|||||||
DownloadFile file = _downloadFiles.FirstOrDefault(x => x.FileID == id);
|
DownloadFile file = _downloadFiles.FirstOrDefault(x => x.FileID == id);
|
||||||
if (file == null)
|
if (file == null)
|
||||||
{
|
{
|
||||||
throw new System.Exception($"File {id} couldn't ne found in list!");
|
Logger.Write($"File {id} couldn't be found in the list!", Logger.LogLevel.Server);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
file.FileWritten += data.Length;
|
file.FileWritten += data.Length;
|
||||||
@ -133,11 +135,11 @@ namespace CoopClient
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Cleanup()
|
public static void Cleanup(bool everything)
|
||||||
{
|
{
|
||||||
lock (_streams) lock (_downloadFiles) lock (_filesFinished)
|
lock (_streams) lock (_downloadFiles) lock (_filesFinished)
|
||||||
{
|
{
|
||||||
foreach (var stream in _streams)
|
foreach (KeyValuePair<byte, FileStream> stream in _streams)
|
||||||
{
|
{
|
||||||
stream.Value.Close();
|
stream.Value.Close();
|
||||||
stream.Value.Dispose();
|
stream.Value.Dispose();
|
||||||
@ -147,9 +149,12 @@ namespace CoopClient
|
|||||||
_filesFinished.Clear();
|
_filesFinished.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (everything)
|
||||||
|
{
|
||||||
DownloadComplete = false;
|
DownloadComplete = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal class DownloadFile
|
internal class DownloadFile
|
||||||
{
|
{
|
||||||
|
@ -133,7 +133,7 @@ namespace CoopClient
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NetConnectionStatus.Disconnected:
|
case NetConnectionStatus.Disconnected:
|
||||||
DownloadManager.Cleanup();
|
DownloadManager.Cleanup(true);
|
||||||
|
|
||||||
// Reset all values
|
// Reset all values
|
||||||
Latency = 0;
|
Latency = 0;
|
||||||
@ -501,6 +501,7 @@ namespace CoopClient
|
|||||||
Packets.FileTransferComplete packet = new Packets.FileTransferComplete();
|
Packets.FileTransferComplete packet = new Packets.FileTransferComplete();
|
||||||
packet.NetIncomingMessageToPacket(data);
|
packet.NetIncomingMessageToPacket(data);
|
||||||
|
|
||||||
|
DownloadManager.Cleanup(false);
|
||||||
DownloadManager.DownloadComplete = true;
|
DownloadManager.DownloadComplete = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<AssemblyVersion>1.47.3.0001</AssemblyVersion>
|
<AssemblyVersion>1.47.4.0001</AssemblyVersion>
|
||||||
<FileVersion>1.0.0.0</FileVersion>
|
<FileVersion>1.0.0.0</FileVersion>
|
||||||
<RepositoryUrl>https://github.com/GTACOOP-R/GTACoop-R</RepositoryUrl>
|
<RepositoryUrl>https://github.com/GTACOOP-R/GTACoop-R</RepositoryUrl>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
@ -70,9 +70,11 @@ namespace CoopServer
|
|||||||
}
|
}
|
||||||
|
|
||||||
newFile.FileData.Add(buffer);
|
newFile.FileData.Add(buffer);
|
||||||
|
Logging.Debug($"[{fileInfo.Name}] {buffer.Length}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logging.Debug($"[{fileInfo.Name}] RESULT {newFile.FileData.Count} / {newFile.FileLength}");
|
||||||
_files.Add(newFile);
|
_files.Add(newFile);
|
||||||
fileCount++;
|
fileCount++;
|
||||||
}
|
}
|
||||||
@ -238,6 +240,8 @@ namespace CoopServer
|
|||||||
|
|
||||||
private void Send(long nethandle, DownloadFile file)
|
private void Send(long nethandle, DownloadFile file)
|
||||||
{
|
{
|
||||||
|
Logging.Debug($"SEND [{file.FileName}][{_fileDataPosition}/{file.FileData.Count - 1}]");
|
||||||
|
|
||||||
NetConnection conn = Server.MainNetServer.Connections.FirstOrDefault(x => x.RemoteUniqueIdentifier == nethandle);
|
NetConnection conn = Server.MainNetServer.Connections.FirstOrDefault(x => x.RemoteUniqueIdentifier == nethandle);
|
||||||
if (conn == null)
|
if (conn == null)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user