Skip to content

Commit

Permalink
- added incoming file space pre-allocation
Browse files Browse the repository at this point in the history
- improved file stream write seeking
  • Loading branch information
firestorm40 committed Aug 24, 2019
1 parent 4338c3d commit 5e68653
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions SPIXI/SPIXI/Data/TransferManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,7 @@ public static bool receiveFileData(byte[] data, byte[] sender)
if (transfer == null)
return false;

//transfer.fileStream.Position = 0;
//transfer.fileStream.Write(file_data, Config.packetDataSize * (int)packet_number, file_data.Length);
transfer.fileStream.Seek(Config.packetDataSize * (int)packet_number, SeekOrigin.Begin);
transfer.fileStream.Write(file_data, 0, file_data.Length);

ulong new_packet_number = packet_number + 1;
Expand Down Expand Up @@ -317,7 +316,7 @@ public static void acceptFile(Friend friend, string uid)

transfer.filepath = String.Format("{0}/Downloads/{1}", Config.spixiUserFolder, transfer.filename);
transfer.fileStream = File.Create(transfer.filepath);

transfer.fileStream.SetLength((long)transfer.filesize);

SpixiMessage spixi_message = new SpixiMessage(Guid.NewGuid().ToByteArray(), SpixiMessageCode.acceptFile, m.ToArray());

Expand Down

0 comments on commit 5e68653

Please sign in to comment.