Skip to content

Commit

Permalink
previousTotal depending on single download thread
Browse files Browse the repository at this point in the history
  • Loading branch information
albertschulz committed Apr 29, 2014
1 parent b507c03 commit e056ff7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,34 @@
<key>IDESourceControlProjectFavoriteDictionaryKey</key>
<false/>
<key>IDESourceControlProjectIdentifier</key>
<string>88303317-EAAE-4C24-A97C-A502FC06B428</string>
<string>F39411CF-86E8-472C-BB23-59E6E7BADCEC</string>
<key>IDESourceControlProjectName</key>
<string>TCBlobDownloadExample</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>B3681C98-7CEA-406E-BF79-4FBCE3FC3E82</key>
<string>https://github.com/thibaultCha/TCBlobDownload</string>
<key>AAF2C7DA-26ED-4FFF-9AAA-45212BB1FAE3</key>
<string>https://github.com/albertschulz/TCBlobDownload</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>Example/TCBlobDownloadExample.xcodeproj/project.xcworkspace</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>B3681C98-7CEA-406E-BF79-4FBCE3FC3E82</key>
<key>AAF2C7DA-26ED-4FFF-9AAA-45212BB1FAE3</key>
<string>../../..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>https://github.com/thibaultCha/TCBlobDownload</string>
<string>https://github.com/albertschulz/TCBlobDownload</string>
<key>IDESourceControlProjectVersion</key>
<integer>110</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>B3681C98-7CEA-406E-BF79-4FBCE3FC3E82</string>
<string>AAF2C7DA-26ED-4FFF-9AAA-45212BB1FAE3</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>B3681C98-7CEA-406E-BF79-4FBCE3FC3E82</string>
<string>AAF2C7DA-26ED-4FFF-9AAA-45212BB1FAE3</string>
<key>IDESourceControlWCCName</key>
<string>TCBlobDownload</string>
</dict>
Expand Down
6 changes: 4 additions & 2 deletions TCBlobDownload/TCBlobDownload/TCBlobDownloader.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
#import "TCBlobDownloader.h"
#import "UIDevice-Hardware.h"

@interface TCBlobDownloader ()
@interface TCBlobDownloader () {
uint64_t previousTotal;
}
// Public
@property (nonatomic, copy, readwrite) NSURL *downloadURL;
@property (nonatomic, copy, readwrite) NSString *pathToFile;
Expand Down Expand Up @@ -134,6 +136,7 @@ - (void)start
[self.file seekToEndOfFile];
_receivedDataBuffer = [[NSMutableData alloc] init];
_samplesOfDownloadedBytes = [[NSMutableArray alloc] init];
previousTotal = 0;
_connection = [[NSURLConnection alloc] initWithRequest:fileRequest
delegate:self
startImmediately:NO];
Expand Down Expand Up @@ -354,7 +357,6 @@ - (void)updateTransferRate
[self.samplesOfDownloadedBytes removeObjectAtIndex:0];
}

static uint64_t previousTotal;
[self.samplesOfDownloadedBytes addObject:[NSNumber numberWithUnsignedLongLong:self.receivedDataLength - previousTotal]];
previousTotal = self.receivedDataLength;
// Compute the speed rate on the average of the last seconds samples
Expand Down

0 comments on commit e056ff7

Please sign in to comment.