Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[expo-file-system] Extract resumables manger
- Loading branch information
Showing
8 changed files
with
92 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
packages/expo-file-system/ios/EXFileSystem/EXSessionTasks/EXResumablesManager.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright 2015-present 650 Industries. All rights reserved. | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface EXResumablesManager : NSObject | ||
|
||
- (NSURLSessionDownloadTask * _Nullable)getTask:(NSString *)uuid; | ||
|
||
- (void)registerTask:(NSURLSessionDownloadTask *)task uuid:(NSString *)uuid; | ||
|
||
- (void)unregisterTask:(NSString *)uuid; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
36 changes: 36 additions & 0 deletions
36
packages/expo-file-system/ios/EXFileSystem/EXSessionTasks/EXResumablesManager.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright 2015-present 650 Industries. All rights reserved. | ||
|
||
#import "EXResumablesManager.h" | ||
|
||
@interface EXResumablesManager () | ||
|
||
@property (nonatomic, strong) NSMutableDictionary<NSString *, NSURLSessionDownloadTask *> *resumableDownloads; | ||
|
||
@end | ||
|
||
@implementation EXResumablesManager | ||
|
||
- (instancetype)init | ||
{ | ||
if (self = [super init]) { | ||
_resumableDownloads = [NSMutableDictionary dictionary]; | ||
} | ||
return self; | ||
} | ||
|
||
- (void)registerTask:(NSURLSessionDownloadTask *)task uuid:(NSString *)uuid | ||
{ | ||
_resumableDownloads[uuid] = task; | ||
} | ||
|
||
- (NSURLSessionDownloadTask * _Nullable)getTask:(NSString *)uuid | ||
{ | ||
return _resumableDownloads[uuid]; | ||
} | ||
|
||
- (void)unregisterTask:(NSString *)uuid | ||
{ | ||
[_resumableDownloads removeObjectForKey:uuid]; | ||
} | ||
|
||
@end |
6 changes: 4 additions & 2 deletions
6
...expo-file-system/ios/EXFileSystem/EXSessionTasks/EXSessionResumableDownloadTaskDelegate.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
// Copyright 2015-present 650 Industries. All rights reserved. | ||
|
||
#import <EXFileSystem/EXSessionDownloadTaskDelegate.h> | ||
#import <EXFileSystem/EXResumablesManager.h> | ||
|
||
typedef void (^EXDownloadDelegateOnWriteCallback)(NSURLSessionDownloadTask *task, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite); | ||
|
||
@interface EXSessionResumableDownloadTaskDelegate : EXSessionDownloadTaskDelegate | ||
|
||
@property (strong, nonatomic, readonly) NSString *uuid; | ||
|
||
- (instancetype)initWithResolve:(UMPromiseResolveBlock)resolve | ||
reject:(UMPromiseRejectBlock)reject | ||
localUrl:(NSURL *)localUrl | ||
shouldCalculateMd5:(BOOL)shouldCalculateMd5 | ||
onWriteCallback:(EXDownloadDelegateOnWriteCallback)onWriteCallback | ||
resumableManager:(EXResumablesManager *)manager | ||
uuid:(NSString *)uuid; | ||
|
||
- (void)invalid; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters