Skip to content

Commit

Permalink
Remove overriden attachmentNamed: from CBLUnsavedRevision
Browse files Browse the repository at this point in the history
- Per code review, removed the overriden attachmentNamed: from the CBLUnsavedRevision class.
- The new added CBLAttachments get from the attachmentNamed: of the CBLUnsavedRevision will not have revision object set. Updated the unit test accordingly.
  • Loading branch information
pasin committed Apr 14, 2015
1 parent a3f6388 commit ed0fc74
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
14 changes: 0 additions & 14 deletions Source/API/CBLRevision.m
Original file line number Diff line number Diff line change
Expand Up @@ -371,24 +371,10 @@ - (void) _addAttachment: (CBLAttachment*)attachment named: (NSString*)name {
// NOTE: Not setting the revision to the attachment object (attachment.revision = self) as
// [1] The UnsavedRevision object is not used during save operation
// [2] Setting the UnsavedRevision object here will cause the circular reference memory leak.
// The revision object will be set in the overridden attachmentName: method.
}

- (void) removeAttachmentNamed: (NSString*)name {
[self _addAttachment: nil named: name];
}

- (CBLAttachment*) attachmentNamed: (NSString*)name {
CBLAttachment* base = self.attachmentMetadata[name];
if (base) {
CBLAttachment* attachment = [[CBLAttachment alloc] _initWithContentType: base.contentType
body: base.body];
attachment.name = name;
attachment.revision = self;
return attachment;
}
return nil;
}


@end
3 changes: 2 additions & 1 deletion Unit-Tests/Database_Tests.m
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,8 @@ - (void) test18_Attachments {
AssertEq(rev2.attachments.count, (NSUInteger)1);
AssertEqual(rev2.attachmentNames, [NSArray arrayWithObject: @"index.html"]);
CBLAttachment* attach = [rev2 attachmentNamed:@"index.html"];
AssertEq(attach.document, doc);
AssertNil(attach.revision); // No revision set
AssertNil(attach.document); // No revision set
AssertEqual(attach.name, @"index.html");
AssertEqual(attach.contentType, @"text/plain; charset=utf-8");
AssertEqual(attach.content, body);
Expand Down

0 comments on commit ed0fc74

Please sign in to comment.