Skip to content

Commit

Permalink
- Cleanups and minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
felix-schwarz committed May 27, 2020
1 parent 2e5ac07 commit 7f7fb1b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 24 deletions.
29 changes: 18 additions & 11 deletions ownCloudSDK/Connection/OCConnection.m
Original file line number Diff line number Diff line change
Expand Up @@ -1362,8 +1362,6 @@ - (OCHTTPPipeline *)transferPipelineForRequest:(OCHTTPRequest *)request withExpe
#pragma mark - File transfer: upload
- (OCProgress *)uploadFileFromURL:(NSURL *)sourceURL withName:(NSString *)fileName to:(OCItem *)newParentDirectory replacingItem:(OCItem *)replacedItem options:(NSDictionary<OCConnectionOptionKey,id> *)options resultTarget:(OCEventTarget *)eventTarget
{
// OCProgress *requestProgress = nil;

if ((sourceURL == nil) || (newParentDirectory == nil))
{
return(nil);
Expand Down Expand Up @@ -1411,6 +1409,13 @@ - (OCProgress *)uploadFileFromURL:(NSURL *)sourceURL withName:(NSString *)fileNa
}
}

// Determine sufficiency of parameters
if ((sourceURL == nil) || (fileName == nil) || (newParentDirectory == nil) || (modDate == nil) || (fileSize == nil))
{
[eventTarget handleError:OCError(OCErrorInsufficientParameters) type:OCEventTypeUpload uuid:nil sender:self];
return(nil);
}

// Compute checksum
__block OCChecksum *checksum = nil;

Expand All @@ -1431,12 +1436,6 @@ - (OCProgress *)uploadFileFromURL:(NSURL *)sourceURL withName:(NSString *)fileNa
});
}

if ((sourceURL == nil) || (fileName == nil) || (newParentDirectory == nil) || (modDate == nil) || (fileSize == nil))
{
[eventTarget handleError:OCError(OCErrorInsufficientParameters) type:OCEventTypeUpload uuid:nil sender:self];
return(nil);
}

// Determine TUS info
OCTUSHeader *parentTusHeader = nil;

Expand Down Expand Up @@ -1707,6 +1706,12 @@ - (OCProgress *)_continueTusJob:(OCTUSJob *)tusJob lastTask:(NSString *)lastTask
// Attach to pipelines
[self attachToPipelines];

// TODO: Apply cellular options
// if (options[OCConnectionOptionAllowCellularKey] != nil)
// {
// request.avoidCellular = ![options[OCConnectionOptionAllowCellularKey] boolValue];
// }

// Enqueue request
// if (options[OCConnectionOptionRequestObserverKey] != nil)
// {
Expand Down Expand Up @@ -1833,10 +1838,12 @@ - (OCEvent *)_errorEventFromRequest:(OCHTTPRequest *)request error:(NSError *)er
}

// Add date to error
#ifdef OCErrorAddDateFromResponse
if (event.error != nil)
{
OCErrorAddDateFromResponse(event.error, request.httpResponse);
}
#endif /* OCErrorAddDateFromResponse */

if (send)
{
Expand Down Expand Up @@ -1934,7 +1941,7 @@ - (OCProgress *)_directUploadFileFromURL:(NSURL *)sourceURL withName:(NSString *

- (void)_handleUploadFileResult:(OCHTTPRequest *)request error:(NSError *)error
{
// Compatibility with previous selector (from before the addition of TUS support)
// Compatibility with previous selector (from before the addition of TUS support) - some Sync Journal entries may still reference this selector
[self _handleDirectUploadFileResult:request error:error];
}

Expand Down Expand Up @@ -1974,8 +1981,7 @@ - (void)_handleDirectUploadFileResult:(OCHTTPRequest *)request error:(NSError *)

// Retrieve item information
[self retrieveItemListAtPath:[parentItem.path stringByAppendingPathComponent:fileName] depth:0 options:@{
@"alternativeEventType" : @(OCEventTypeUpload),
// @"_originalUserInfo" : request.userInfo
@"alternativeEventType" : @(OCEventTypeUpload)
} resultTarget:request.eventTarget];
}
else
Expand Down Expand Up @@ -2098,6 +2104,7 @@ - (OCProgress *)downloadItem:(OCItem *)item to:(NSURL *)targetURL options:(NSDic

[request setValue:item.eTag forHeaderField:@"If-Match"];

// Apply cellular options
if (options[OCConnectionOptionAllowCellularKey] != nil)
{
request.avoidCellular = ![options[OCConnectionOptionAllowCellularKey] boolValue];
Expand Down
9 changes: 0 additions & 9 deletions ownCloudSDK/Item/OCItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,6 @@ typedef NS_ENUM(NSInteger, OCItemCloudStatus)
OCItemCloudStatusLocalOnly //!< Item only exists locally. There's no remote copy.
};

typedef NS_OPTIONS(NSInteger, OCUploadMethod)
{
OCUploadMethodUnknown = 0,

OCUploadMethodStandard = (1 << 0), //!< Standard HTTP PUT uploads supported
OCUploadMethodChunked = (1 << 1), //!< OC10 chunked uploads supported
OCUploadMethodTUS = (1 << 2) //!< TUS uploads supported
};

#import "OCShare.h"

NS_ASSUME_NONNULL_BEGIN
Expand Down
4 changes: 0 additions & 4 deletions ownCloudSDK/TUS/OCTUSHeader.m
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,6 @@ - (OCHTTPHeaderFields)httpHeaderFields
{
headerFields[OCTUSHeaderNameTusVersion] = [_versions componentsJoinedByString:@","];
}
// else if (_version != nil)
// {
// headerFields[OCTUSHeaderNameTusVersion] = _version;
// }

if (_extensions != nil)
{
Expand Down

0 comments on commit 7f7fb1b

Please sign in to comment.