From d7f0855471164b21db68677cceb7c432b969f80b Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Mon, 13 Apr 2015 11:47:17 -0700 Subject: [PATCH 1/2] Remove NSDataReadingMappedIfSafe when reading attachment content NSDataReadingMappedIfSafe option can keep the file descriptors of the attachments open if the client application keeps holding the NSData object returned by CBLAttachment.content. For a very big attachment, alternatively, users can call contentURL and read the NSData with the NSDataReadingMappedIfSafe option themselves. #649 --- Source/API/CBLAttachment.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/API/CBLAttachment.m b/Source/API/CBLAttachment.m index 0fd1a8594..dee2dfb88 100644 --- a/Source/API/CBLAttachment.m +++ b/Source/API/CBLAttachment.m @@ -118,7 +118,7 @@ - (NSData*) content { return _body; else if ([_body isKindOfClass: [NSURL class]] && [_body isFileURL]) { return [NSData dataWithContentsOfURL: _body - options: NSDataReadingMappedIfSafe | NSDataReadingUncached + options: NSDataReadingUncached error: nil]; } return nil; From c073243c2c5d052fedeee3994c6c0862bab7b6cd Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Mon, 13 Apr 2015 16:17:16 -0700 Subject: [PATCH 2/2] Remove NSDataReadingMappedIfSafe from CBL_BlobStore.blobForKey Remove NSDataReadingMappedIfSafe and use NSDataReadingUncached option when reading blob data for a key. #649 --- Source/CBL_BlobStore.m | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Source/CBL_BlobStore.m b/Source/CBL_BlobStore.m index dc855ca7c..b76fd0f1e 100644 --- a/Source/CBL_BlobStore.m +++ b/Source/CBL_BlobStore.m @@ -120,8 +120,7 @@ - (BOOL) hasBlobForKey: (CBLBlobKey)key { - (NSData*) blobForKey: (CBLBlobKey)key { NSString* path = [self rawPathForKey: key]; - NSData* blob = [NSData dataWithContentsOfFile: path options: NSDataReadingMappedIfSafe - error: NULL]; + NSData* blob = [NSData dataWithContentsOfFile: path options: NSDataReadingUncached error: NULL]; if (_encryptionKey && blob) { blob = [_encryptionKey decryptData: blob]; CBLBlobKey decodedKey = [[self class] keyForBlob: blob];