Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified Assets/PatchKit Patcher/Library/PatchKit.Network.dll
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;
using System.Net;
using JetBrains.Annotations;
Expand Down Expand Up @@ -79,7 +79,8 @@ public void Download(CancellationToken cancellationToken)
{
Address = new Uri(_url),
Range = _bytesRange,
Timeout = _timeout
Timeout = _timeout,
ReadWriteTimeout = _timeout,
};

using (var response = _httpClient.Get(request))
Expand Down
84 changes: 0 additions & 84 deletions Assets/PatchKit Patcher/Scripts/Utilities/BytesRangeHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,89 +54,5 @@ public static BytesRange Chunkify(this BytesRange range, ChunksData chunksData)

return new BytesRange(bottom, top);
}

/// <summary>
/// Limits one range inside the other, examples:
/// 0:-1 contained in range 20:30 becomes 20:30.
/// 0:100 contained in range 50:-1 becomes 50:100
/// </summary>
public static BytesRange ContainIn(this BytesRange range, BytesRange outer)
{
if (Contains(outer, range))
{
return range;
}

long start = range.Start;
long end = range.End;

if (range.Start < outer.Start)
{
start = outer.Start;
}

if (outer.End != -1)
{
if (range.End == -1 || range.End > outer.End)
{
end = outer.End;
}
}

return Make(start, end);
}

/// <summary>
/// Localizes one range inside another, the resulting range is limited and local to the relative ("parent") range
/// If the ranges don't overlap, an empty range will be returned.
/// Examples:
/// 50:95 localized within 10:90 becomes 40:-1
/// 5:15 localized within 10:90 becomes 0:5
/// </summary>
public static BytesRange LocalizeTo(this BytesRange range, BytesRange relative)
{
if (!Overlaps(range, relative))
{
return Empty();
}

long localStart = range.Start >= relative.Start ? range.Start - relative.Start : 0;
long localEnd = range.End <= relative.End ? range.End - relative.Start : -1;

if (range.End == -1)
{
localEnd = -1;
}

return Make(localStart, localEnd);
}

public static bool Overlaps(this BytesRange lhs, BytesRange rhs)
{
return Contains(lhs, rhs)
|| Contains(rhs, lhs)
|| Contains(lhs, rhs.Start)
|| Contains(lhs, rhs.End);
}

public static bool Contains(this BytesRange outer, BytesRange inner)
{
if (inner.End == -1 && outer.End != -1)
{
return false;
}

if (inner.Start >= outer.Start)
{
return outer.End == -1 || inner.End <= outer.End;
}

return false;
}

public static bool Contains(this BytesRange range, long value)
{
return value >= range.Start && (range.End == -1 || value <= range.End);
}
}
}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
### Changed
- Patcher will timeout if the downloading stopped sooner than after 5 minutes

## [3.10.1]
### Fixed
- Updated torrent-client to fix the issue with paths with spaces in them
Expand Down