Skip to content

Commit

Permalink
Merge branch 'release-1.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
odrobnik committed Aug 6, 2013
2 parents cd3e2e3 + ba16b42 commit 2547f3a
Show file tree
Hide file tree
Showing 19 changed files with 888 additions and 51 deletions.
26 changes: 25 additions & 1 deletion Core/Source/DTDownload.m
Original file line number Diff line number Diff line change
Expand Up @@ -327,11 +327,35 @@ - (void)_completeWithSuccess
return;
}

if (![fileManager removeItemAtPath:[_destinationBundleFilePath stringByDeletingLastPathComponent] error:&error]) {
if (![fileManager removeItemAtPath:[_destinationBundleFilePath stringByDeletingLastPathComponent] error:&error])
{
NSLog(@"Cannot remove item from %@, %@ ", [_destinationBundleFilePath stringByDeletingLastPathComponent], [error localizedDescription]);
}

NSData *data = [NSData dataWithContentsOfFile:targetPath options:NSDataReadingMappedIfSafe error:&error];

if (error)
{
NSLog(@"Error occured when reading file from path: %@", targetPath);
}

// Error: finished file size differs from header size -> so throw error
if (_expectedContentLength>0 && [data length] != _expectedContentLength)
{
NSString *errorMessage = [NSString stringWithFormat:@"Error: finished file size %d differs from header size %d", (int)[data length], (int)_expectedContentLength];

NSLog(errorMessage, nil);

NSDictionary *userInfo = @{errorMessage : NSLocalizedDescriptionKey};

NSError *error = [NSError errorWithDomain:@"DTDownloadError" code:1 userInfo:userInfo];

[self _completeWithError:error];

return;
}


// notify delegate
if ([_delegate respondsToSelector:@selector(download:didFinishWithFile:)])
{
Expand Down
19 changes: 11 additions & 8 deletions Core/Source/DTDownloadCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ - (NSData *)cachedDataForURL:(NSURL *)URL option:(DTDownloadCacheOption)option c
case DTDownloadCacheOptionReturnCacheAndLoadAlways:
{
cachedFile.forceLoad = [NSNumber numberWithBool:YES];
cachedFile.abortDownloadIfNotChanged = @(NO);

break;
}
Expand Down Expand Up @@ -392,12 +393,14 @@ - (void)download:(DTDownload *)download didFinishWithFile:(NSString *)path
NSURL *URL = download.URL;

[_workerContext performBlock:^{
NSData *data = [NSData dataWithContentsOfMappedFile:path];

if (download.expectedContentLength>0 && [data length] != download.expectedContentLength)
{
NSLog(@"Warning: finished file size %d differs from header size %d", (int)[data length], (int)download.expectedContentLength);
}
NSError *error = nil;
NSData *data = [NSData dataWithContentsOfFile:path options:NSDataReadingMappedIfSafe error:&error];

if (error)
{
NSLog(@"Error occured when reading file from path: %@", path);
}

// only add cached file if we actually got data in it
if (data)
Expand Down Expand Up @@ -932,14 +935,15 @@ @implementation DTDownloadCache (Images)

- (UIImage *)cachedImageForURL:(NSURL *)URL option:(DTDownloadCacheOption)option completion:(DTDownloadCacheImageCompletionBlock)completion
{

// try memory cache first
UIImage *cachedImage = [_memoryCache objectForKey:URL];

if (cachedImage)
if (cachedImage && !DTDownloadCacheOptionReturnCacheAndLoadAlways)
{
return cachedImage;
}

// create a special wrapper completion handler
DTDownloadCacheDataCompletionBlock internalBlock = NULL;

Expand Down Expand Up @@ -970,7 +974,6 @@ - (UIImage *)cachedImageForURL:(NSURL *)URL option:(DTDownloadCacheOption)option
};
}


// try file cache
NSData *data = [self cachedDataForURL:URL option:option completion:internalBlock];

Expand Down
5 changes: 2 additions & 3 deletions DTDownload.podspec
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
Pod::Spec.new do |spec|
spec.name = 'DTDownload'
spec.version = '1.0.1'
spec.version = '1.0.2'
spec.summary = "File Downloading, Caching and Queueing."
spec.homepage = "https://github.com/Cocoanetics/DTDownload"
spec.author = { "Oliver Drobnik" => "oliver@drobnik.com" }
spec.source = { :git => "https://github.com/Cocoanetics/DTDownload.git", :tag => spec.version.to_s }
spec.platform = :ios
spec.ios.deployment_target = '5.0'
spec.dependency 'DTFoundation/Core', '~>1.4.3'
spec.dependency 'DTFoundation/UIKit', '~>1.4.3'
spec.dependency 'DTFoundation/Core', '~>1.5.0'
spec.source_files = 'Core/Source/*.{h,m}'
spec.frameworks = ['CoreData']
spec.license = 'BSD'
Expand Down
370 changes: 332 additions & 38 deletions DTDownload.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions Documentation/Change Log-template.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ Change Log

This is the history of version updates.

**Version 1.0.2**

- ADDED: Sample for DTDownloadCache
- FIXED: Support for web servers that don't support partial content for resuming

**Version 1.0.1**

- FIXED: Downloads would be corrupted if requesting partial file from server that didn't support that
Expand Down
2 changes: 1 addition & 1 deletion Externals/DTFoundation
Submodule DTFoundation updated 93 files
+1 −1 AppledocSettings.plist
+2 −1 Core/DTFoundation.h
+0 −0 Core/Source/DTASN1/DTASN1BitString.h
+0 −0 Core/Source/DTASN1/DTASN1BitString.m
+117 −5 Core/Source/DTASN1/DTASN1Parser.h
+1 −1 Core/Source/DTASN1/DTASN1Parser.m
+0 −0 Core/Source/DTASN1/DTASN1Serialization.h
+0 −3 Core/Source/DTASN1/DTASN1Serialization.m
+30 −0 Core/Source/DTAWS/NSURL+DTAWS.h
+85 −0 Core/Source/DTAWS/NSURL+DTAWS.m
+0 −0 Core/Source/DTAsyncFileDeleter.h
+6 −0 Core/Source/DTAsyncFileDeleter.m
+1 −1 Core/Source/DTExtendedFileAttributes.m
+48 −0 Core/Source/DTFolderMonitor.h
+106 −0 Core/Source/DTFolderMonitor.m
+37 −4 Core/Source/DTHTMLParser/DTHTMLParser.m
+132 −0 Core/Source/DTLog.h
+22 −0 Core/Source/DTLog.m
+3 −3 Core/Source/DTReachability/DTReachability.m
+1 −1 Core/Source/DTSQLite/DTSQLiteDatabase.m
+1 −1 Core/Source/DTSQLite/DTSQLiteFunctions.m
+0 −0 Core/Source/DTScripting/DTScriptExpression.h
+8 −7 Core/Source/DTScripting/DTScriptExpression.m
+0 −0 Core/Source/DTScripting/DTScriptVariable.h
+0 −0 Core/Source/DTScripting/DTScriptVariable.m
+0 −0 Core/Source/DTScripting/NSScanner+DTScripting.h
+3 −2 Core/Source/DTScripting/NSScanner+DTScripting.m
+6 −6 Core/Source/DTVersion.m
+38 −6 Core/Source/DTZipArchive/DTZipArchive.h
+66 −5 Core/Source/DTZipArchive/DTZipArchive.m
+268 −182 Core/Source/DTZipArchive/DTZipArchiveGZip.m
+11 −4 Core/Source/DTZipArchive/DTZipArchiveNode.h
+10 −0 Core/Source/DTZipArchive/DTZipArchiveNode.m
+2 −0 Core/Source/DTZipArchive/DTZipArchivePKZip.h
+57 −9 Core/Source/DTZipArchive/DTZipArchivePKZip.m
+2 −2 Core/Source/OSX/NSWindowController+DTPanelControllerPresenting.m
+0 −0 Core/Source/Runtime/DTObjectBlockExecutor.h
+0 −0 Core/Source/Runtime/DTObjectBlockExecutor.m
+0 −0 Core/Source/Runtime/NSObject+DTRuntime.h
+0 −0 Core/Source/Runtime/NSObject+DTRuntime.m
+0 −0 Core/Source/iOS/BlocksAdditions/DTActionSheet.h
+2 −2 Core/Source/iOS/BlocksAdditions/DTActionSheet.m
+0 −0 Core/Source/iOS/BlocksAdditions/DTAlertView.h
+0 −0 Core/Source/iOS/BlocksAdditions/DTAlertView.m
+0 −0 Core/Source/iOS/BlocksAdditions/UIView+DTActionHandlers.h
+0 −0 Core/Source/iOS/BlocksAdditions/UIView+DTActionHandlers.m
+4 −6 Core/Source/iOS/DTActivityTitleView.h
+5 −5 Core/Source/iOS/DTActivityTitleView.m
+23 −17 Core/Source/iOS/DTCustomColoredAccessory.h
+20 −11 Core/Source/iOS/DTSidePanel/DTSidePanelController.h
+2 −1 Core/Source/iOS/DTSidePanel/DTSidePanelController.m
+7 −1 Core/Source/iOS/DTSmartPagingScrollView.h
+42 −42 Core/Source/iOS/DTSmartPagingScrollView.m
+0 −0 Core/Source/iOS/Debug/UIColor+DTDebug.h
+0 −0 Core/Source/iOS/Debug/UIColor+DTDebug.m
+0 −0 Core/Source/iOS/Debug/UIView+DTDebug.h
+2 −1 Core/Source/iOS/Debug/UIView+DTDebug.m
+5 −7 Core/Source/iOS/Experimental/DTStripedLayer.m
+12 −0 Core/Source/iOS/UIImage+DTFoundation.h
+27 −6 Core/Source/iOS/UIImage+DTFoundation.m
+29 −8 DTFoundation.podspec
+674 −232 DTFoundation.xcodeproj/project.pbxproj
+1 −0 Demo/DTReachability/DTReachability-Prefix.pch
+1 −0 Demo/DTSidePanels/DTSidePanels-Prefix.pch
+6 −6 Demo/DTSidePanels/Source/DemoViewController.m
+6 −6 Demo/DTSidePanels/Source/LoggingNavigationController.m
+10 −12 Demo/DTSidePanels/Source/ModalPanelViewController.m
+9 −9 Demo/DTSidePanels/Source/TableViewController.m
+55 −0 Demo/DTZipArchiveDemo/DTZipArchiveDemo-Info.plist
+15 −0 Demo/DTZipArchiveDemo/DTZipArchiveDemo-Prefix.pch
+ Demo/DTZipArchiveDemo/Resources/Default-568h@2x.png
+ Demo/DTZipArchiveDemo/Resources/Default.png
+ Demo/DTZipArchiveDemo/Resources/Default@2x.png
+90 −0 Demo/DTZipArchiveDemo/Resources/Storyboard.storyboard
+15 −0 Demo/DTZipArchiveDemo/Source/AppDelegate.h
+63 −0 Demo/DTZipArchiveDemo/Source/AppDelegate.m
+15 −0 Demo/DTZipArchiveDemo/Source/ViewController.h
+176 −0 Demo/DTZipArchiveDemo/Source/ViewController.m
+29 −0 Demo/DTZipArchiveDemo/Source/ZIpArchiveModel.h
+15 −0 Demo/DTZipArchiveDemo/Source/ZipArchiveCell.h
+29 −0 Demo/DTZipArchiveDemo/Source/ZipArchiveCell.m
+28 −0 Demo/DTZipArchiveDemo/Source/ZipArchiveManager.h
+86 −0 Demo/DTZipArchiveDemo/Source/ZipArchiveManager.m
+60 −0 Demo/DTZipArchiveDemo/Source/ZipArchiveModel.m
+23 −0 Demo/DTZipArchiveDemo/Source/ZipNodeViewController.h
+217 −0 Demo/DTZipArchiveDemo/Source/ZipNodeViewController.m
+18 −0 Demo/DTZipArchiveDemo/Source/main.m
+32 −0 Documentation/Change Log-template.markdown
+0 −4 Test/Source/DTBase64CodingTest.m
+1 −1 Test/Source/DTHTMLParserTest.m
+0 −1 Test/Source/DTScriptingTest.m
+0 −7 Test/Source/DTVersionTest.m
+108 −7 Test/Source/DTZipArchiveTest.m
15 changes: 15 additions & 0 deletions ImageDownloadSample/AppDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// AppDelegate.h
// ImageDownloadSample
//
// Created by Stefan Gugarel on 7/11/13.
// Copyright (c) 2013 Drobnik KG. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@end
46 changes: 46 additions & 0 deletions ImageDownloadSample/AppDelegate.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// AppDelegate.m
// ImageDownloadSample
//
// Created by Stefan Gugarel on 7/11/13.
// Copyright (c) 2013 Drobnik KG. All rights reserved.
//

#import "AppDelegate.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
Binary file added ImageDownloadSample/Default-568h@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ImageDownloadSample/Default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ImageDownloadSample/Default@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions ImageDownloadSample/ImageDownloadSample-Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.drobnik.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIMainStoryboardFile</key>
<string>MainStoryboard_iPhone</string>
<key>UIMainStoryboardFile~ipad</key>
<string>MainStoryboard_iPad</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
14 changes: 14 additions & 0 deletions ImageDownloadSample/ImageDownloadSample-Prefix.pch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// Prefix header for all source files of the 'ImageDownloadSample' target in the 'ImageDownloadSample' project
//

#import <Availability.h>

#ifndef __IPHONE_5_0
#warning "This project uses features only available in iOS SDK 5.0 and later."
#endif

#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif
23 changes: 23 additions & 0 deletions ImageDownloadSample/ViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// ViewController.h
// ImageDownloadSample
//
// Created by Stefan Gugarel on 7/11/13.
// Copyright (c) 2013 Drobnik KG. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController

@property (weak, nonatomic) IBOutlet UIActivityIndicatorView *activityIndicatorView;

@property (weak, nonatomic) IBOutlet UIImageView *imageView;

@property (weak, nonatomic) IBOutlet UILabel *statusLabel;

@property (weak, nonatomic) IBOutlet UIPickerView *downloadOptionPickerView;

- (IBAction)reloadButtonPressed:(UIButton *)sender;

@end
Loading

0 comments on commit 2547f3a

Please sign in to comment.