PackageWriterImpl::_AddEntry(): Fix update logic
* Don't only look up the entry attribute when the entry is implicit. Look it up, when it is a directory instead. This aligns it the logic with _UpdateCheckEntryCollisions(). * When the entry attribute exits and the entry is not implicit, add file attributes, but not stat data. This also aligns the logic with _UpdateCheckEntryCollisions(), which removes colliding attributes, but keeps stat data.
This commit is contained in:
@@ -1567,9 +1567,10 @@ PackageWriterImpl::_AddEntry(int dirFD, Entry* entry, const char* fileName,
|
|||||||
|
|
||||||
// In update mode we don't need to add an entry attribute for an implicit
|
// In update mode we don't need to add an entry attribute for an implicit
|
||||||
// directory, if there already is one.
|
// directory, if there already is one.
|
||||||
if (isImplicitEntry && (Flags() & B_HPKG_WRITER_UPDATE_PACKAGE) != 0) {
|
Attribute* entryAttribute = NULL;
|
||||||
Attribute* entryAttribute = fTopAttribute->FindEntryChild(fileName);
|
if (S_ISDIR(st.st_mode) && (Flags() & B_HPKG_WRITER_UPDATE_PACKAGE) != 0) {
|
||||||
if (entryAttribute != NULL) {
|
entryAttribute = fTopAttribute->FindEntryChild(fileName);
|
||||||
|
if (entryAttribute != NULL && isImplicitEntry) {
|
||||||
Stacker<Attribute> entryAttributeStacker(fTopAttribute,
|
Stacker<Attribute> entryAttributeStacker(fTopAttribute,
|
||||||
entryAttribute);
|
entryAttribute);
|
||||||
_AddDirectoryChildren(entry, fd, pathBuffer);
|
_AddDirectoryChildren(entry, fd, pathBuffer);
|
||||||
@@ -1596,11 +1597,16 @@ PackageWriterImpl::_AddEntry(int dirFD, Entry* entry, const char* fileName,
|
|||||||
throw status_t(B_UNSUPPORTED);
|
throw status_t(B_UNSUPPORTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add attribute entry
|
// add attribute entry, if it doesn't already exist (update mode, directory)
|
||||||
Attribute* entryAttribute = _AddStringAttribute(
|
bool isNewEntry = entryAttribute == NULL;
|
||||||
|
if (entryAttribute == NULL) {
|
||||||
|
entryAttribute = _AddStringAttribute(
|
||||||
B_HPKG_ATTRIBUTE_ID_DIRECTORY_ENTRY, fileName);
|
B_HPKG_ATTRIBUTE_ID_DIRECTORY_ENTRY, fileName);
|
||||||
|
}
|
||||||
|
|
||||||
Stacker<Attribute> entryAttributeStacker(fTopAttribute, entryAttribute);
|
Stacker<Attribute> entryAttributeStacker(fTopAttribute, entryAttribute);
|
||||||
|
|
||||||
|
if (isNewEntry) {
|
||||||
// add stat data
|
// add stat data
|
||||||
if (fileType != B_HPKG_DEFAULT_FILE_TYPE)
|
if (fileType != B_HPKG_DEFAULT_FILE_TYPE)
|
||||||
_AddAttribute(B_HPKG_ATTRIBUTE_ID_FILE_TYPE, fileType);
|
_AddAttribute(B_HPKG_ATTRIBUTE_ID_FILE_TYPE, fileType);
|
||||||
@@ -1640,6 +1646,7 @@ PackageWriterImpl::_AddEntry(int dirFD, Entry* entry, const char* fileName,
|
|||||||
path[bytesRead] = '\0';
|
path[bytesRead] = '\0';
|
||||||
_AddStringAttribute(B_HPKG_ATTRIBUTE_ID_SYMLINK_PATH, path);
|
_AddStringAttribute(B_HPKG_ATTRIBUTE_ID_SYMLINK_PATH, path);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// add attributes
|
// add attributes
|
||||||
if (DIR* attrDir = fs_fopen_attr_dir(fd)) {
|
if (DIR* attrDir = fs_fopen_attr_dir(fd)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user