mirror of
https://review.haiku-os.org/haiku
synced 2025-01-31 10:47:14 +01:00
Fix MIME type creation error
DatabaseLocation::OpenOrCreateType(): BNode::WriteAttr() returns the number of bytes written, not just an error code., so we erroneously reported an error on success. Fixes the first part of #9845.
This commit is contained in:
parent
4f82f6fa72
commit
c09ec54a59
@ -114,8 +114,14 @@ DatabaseLocation::OpenOrCreateType(const char* type, BNode& _node,
|
||||
return error;
|
||||
|
||||
// write the type attribute
|
||||
error = _node.WriteAttr(kTypeAttr, B_STRING_TYPE, 0, type,
|
||||
strlen(type) + 1);
|
||||
size_t toWrite = strlen(type) + 1;
|
||||
ssize_t bytesWritten = _node.WriteAttr(kTypeAttr, B_STRING_TYPE, 0, type,
|
||||
toWrite);
|
||||
if (bytesWritten < 0)
|
||||
error = bytesWritten;
|
||||
else if ((size_t)bytesWritten != toWrite)
|
||||
error = B_FILE_ERROR;
|
||||
|
||||
if (error != B_OK) {
|
||||
_node.Unset();
|
||||
return error;
|
||||
|
Loading…
x
Reference in New Issue
Block a user