Skip to content

Commit

Permalink
VMPythonResourceDownloader: Update property downloadingOperationQueue
Browse files Browse the repository at this point in the history
  • Loading branch information
Kjuly committed Jul 17, 2020
1 parent a7f376e commit f690aa1
Showing 1 changed file with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ @implementation VMPythonResourceDownloader

- (void)dealloc
{
if (self.downloadingOperationQueue) {
[self.downloadingOperationQueue cancelAllOperations];
if (_downloadingOperationQueue) {
[_downloadingOperationQueue cancelAllOperations];
}
}

Expand All @@ -82,6 +82,19 @@ - (instancetype)init

#pragma mark - Getter

- (NSOperationQueue *)downloadingOperationQueue
{
if (!_downloadingOperationQueue) {
_downloadingOperationQueue = [[NSOperationQueue alloc] init];
_downloadingOperationQueue.maxConcurrentOperationCount = 1;
_downloadingOperationQueue.suspended = self.suspended;
_downloadingOperationQueue.qualityOfService = NSQualityOfServiceUtility;
}
// Set `suspended=YES` if want to pause all operations temporary.
//self.downloadingOperationQueue.suspended = YES;
return _downloadingOperationQueue;
}

- (NSCharacterSet *)invalidFilenameCharacterSet
{
if (!_invalidFilenameCharacterSet) {
Expand Down Expand Up @@ -221,9 +234,7 @@ - (void)setSuspended:(BOOL)suspended
{
_suspended = suspended;

if (self.downloadingOperationQueue) {
self.downloadingOperationQueue.suspended = self.suspended;
}
self.downloadingOperationQueue.suspended = self.suspended;
}

#pragma mark - Public
Expand Down Expand Up @@ -308,14 +319,6 @@ - (NSString *)downloadWithURLString:(NSString *)urlString
preferredName:(NSString *)preferredName
userInfo:(NSDictionary *)userInfo
{
if (!self.downloadingOperationQueue) {
self.downloadingOperationQueue = [[NSOperationQueue alloc] init];
self.downloadingOperationQueue.maxConcurrentOperationCount = 1;
self.downloadingOperationQueue.suspended = self.suspended;
}
// Set `suspended=YES` if want to pause all operations temporary.
//self.downloadingOperationQueue.suspended = YES;

VMPythonDownloadOperation *operation = [[VMPythonDownloadOperation alloc] initWithURLString:urlString
inFormat:format
totalFileSize:totalFileSize
Expand Down

0 comments on commit f690aa1

Please sign in to comment.