Commit 4ee55279 authored by Tobias's avatar Tobias

always transfer library on changes if a watch is paired

cancel old outstanding library transfers before starting the next one
parent ae7f6fb5
......@@ -176,7 +176,7 @@ static VLCWatchCommunication *_singeltonInstance = nil;
}
- (void)copyCoreDataToWatch {
if (![[WCSession defaultSession] isReachable]) return;
if (![[WCSession defaultSession] isPaired]) return;
MLMediaLibrary *library = [MLMediaLibrary sharedMediaLibrary];
NSPersistentStoreCoordinator *libraryPSC = [library persistentStoreCoordinator];
......@@ -192,6 +192,14 @@ static VLCWatchCommunication *_singeltonInstance = nil;
NSLog(@"%s failed to copy persistent store to tmp location for copy to watch with error %@",__PRETTY_FUNCTION__,error);
}
// cancel old transfers
NSArray<WCSessionFileTransfer *> *outstandingtransfers = [[WCSession defaultSession] outstandingFileTransfers];
[outstandingtransfers enumerateObjectsUsingBlock:^(WCSessionFileTransfer * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if ([obj.file.metadata[@"filetype"] isEqualToString:@"coredata"]) {
[obj cancel];
}
}];
NSDictionary *metadata = @{@"filetype":@"coredata"};
[[WCSession defaultSession] transferFile:tmpURL metadata:metadata];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment