Skip to content

Commit

Permalink
When writing the last chunk, only write the remaining data amount not…
Browse files Browse the repository at this point in the history
… the full buffer size
  • Loading branch information
FerasArabiat committed Mar 22, 2019
1 parent d869636 commit b6040db
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions SplitNSP-Swift-GUI/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,10 @@ class ViewController: NSViewController, ADragDropViewDelegate {

while partSize < remainingSize {
autoreleasepool {

inputStream.read(buffer, maxLength: chunkSize)
outStream.write(buffer, maxLength: chunkSize)
partSize += chunkSize
totalCompleted += chunkSize
let readLength = inputStream.read(buffer, maxLength: chunkSize)
outStream.write(buffer, maxLength: readLength)
partSize += readLength
totalCompleted += readLength

partProgressValue.completedUnitCount = Int64(partSize)
nspProgressValue.completedUnitCount = Int64(totalCompleted)
Expand Down

0 comments on commit b6040db

Please sign in to comment.