diff --git a/ASIHTTPRequest.podspec b/ASIHTTPRequest.podspec new file mode 100644 index 00000000..ce7851e3 --- /dev/null +++ b/ASIHTTPRequest.podspec @@ -0,0 +1,45 @@ +Pod::Spec.new do |s| + s.name = 'ASIHTTPRequest' + s.version = '1.8.1' + s.summary = 'Easy to use CFNetwork wrapper for HTTP requests, Objective-C, Mac OS X and iPhone.' + s.homepage = 'http://allseeing-i.com/ASIHTTPRequest' + s.author = { 'Ben Copsey' => 'ben@allseeing-i.com' } + s.license = 'New BSD License' + s.source = { :git => 'https://github.com/hs1512/ASIHTTPRequest', :tag => 'v1.8.1' } + + s.description = %{ + ASIHTTPRequest is an easy to use wrapper around the CFNetwork API that + makes some of the more tedious aspects of communicating with web servers + easier. It is written in Objective-C and works in both Mac OS X and iPhone + applications. + + It is suitable performing basic HTTP requests and interacting with + REST-based services (GET / POST / PUT / DELETE). The included + ASIFormDataRequest subclass makes it easy to submit POST data and files + using multipart/form-data. + } + + s.source_files = 'Classes' + + s.ios.dependency 'Reachability' #, '~> 2.0', '>= 2.0.4' + s.ios.frameworks = 'MobileCoreServices', 'CFNetwork', 'CoreGraphics' + + s.osx.exclude_files = '**/*ASIAuthenticationDialog*' + s.osx.frameworks = 'SystemConfiguration', 'CoreServices' + + s.library = 'z.1' + + s.subspec 'ASIWebPageRequest' do |ws| + ws.source_files = 'Classes/ASIWebPageRequest/' + ws.library = 'xml2.2' + ws.xcconfig = { 'HEADER_SEARCH_PATHS' => '"$(SDKROOT)/usr/include/libxml2"' } + end + + s.subspec 'CloudFiles' do |cfs| + cfs.source_files = 'Classes/CloudFiles/' + end + + s.subspec 'S3' do |s3s| + s3s.source_files = 'Classes/S3/' + end +end diff --git a/Classes/ASIHTTPRequest.m b/Classes/ASIHTTPRequest.m index 31756d2b..9617bdf4 100644 --- a/Classes/ASIHTTPRequest.m +++ b/Classes/ASIHTTPRequest.m @@ -10,7 +10,7 @@ // Portions are based on the ImageClient example from Apple: // See: http://developer.apple.com/samplecode/ImageClient/listing37.html -#import "ASIHTTPRequest.h" +#import "ASIHTTPRequest.h"if (![[self class] removeFileAtPath:[self downloadDestinationPath] error:&moveError]) { #if TARGET_OS_IPHONE #import "Reachability.h" @@ -3458,22 +3458,25 @@ - (void)handleStreamComplete } else { - //Remove any file at the destination path - NSError *moveError = nil; - if (![[self class] removeFileAtPath:[self downloadDestinationPath] error:&moveError]) { - fileError = moveError; - - } - - //Move the temporary file to the destination path - if (!fileError) { - [[[[NSFileManager alloc] init] autorelease] moveItemAtPath:[self temporaryFileDownloadPath] toPath:[self downloadDestinationPath] error:&moveError]; - if (moveError) { - fileError = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASIFileManagementError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Failed to move file from '%@' to '%@'",[self temporaryFileDownloadPath],[self downloadDestinationPath]],NSLocalizedDescriptionKey,moveError,NSUnderlyingErrorKey,nil]]; + //James Jeong edited. + if (![[self temporaryFileDownloadPath] isEqualToString:[self downloadDestinationPath]]) { + //Remove any file at the destination path + NSError *moveError = nil; + if (![[self class] removeFileAtPath:[self downloadDestinationPath] error:&moveError]) { + fileError = moveError; + + } + + //Move the temporary file to the destination path + if (!fileError) { + [[[[NSFileManager alloc] init] autorelease] moveItemAtPath:[self temporaryFileDownloadPath] toPath:[self downloadDestinationPath] error:&moveError]; + if (moveError) { + fileError = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASIFileManagementError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Failed to move file from '%@' to '%@'",[self temporaryFileDownloadPath],[self downloadDestinationPath]],NSLocalizedDescriptionKey,moveError,NSUnderlyingErrorKey,nil]]; + } + //[self setTemporaryFileDownloadPath:nil]; } - [self setTemporaryFileDownloadPath:nil]; } - + [self setTemporaryFileDownloadPath:nil]; } }