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:
parent
3095cb1bc9
commit
718fba99c8
@ -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
|
||||
// directory, if there already is one.
|
||||
if (isImplicitEntry && (Flags() & B_HPKG_WRITER_UPDATE_PACKAGE) != 0) {
|
||||
Attribute* entryAttribute = fTopAttribute->FindEntryChild(fileName);
|
||||
if (entryAttribute != NULL) {
|
||||
Attribute* entryAttribute = NULL;
|
||||
if (S_ISDIR(st.st_mode) && (Flags() & B_HPKG_WRITER_UPDATE_PACKAGE) != 0) {
|
||||
entryAttribute = fTopAttribute->FindEntryChild(fileName);
|
||||
if (entryAttribute != NULL && isImplicitEntry) {
|
||||
Stacker<Attribute> entryAttributeStacker(fTopAttribute,
|
||||
entryAttribute);
|
||||
_AddDirectoryChildren(entry, fd, pathBuffer);
|
||||
@ -1596,11 +1597,16 @@ PackageWriterImpl::_AddEntry(int dirFD, Entry* entry, const char* fileName,
|
||||
throw status_t(B_UNSUPPORTED);
|
||||
}
|
||||
|
||||
// add attribute entry
|
||||
Attribute* entryAttribute = _AddStringAttribute(
|
||||
// add attribute entry, if it doesn't already exist (update mode, directory)
|
||||
bool isNewEntry = entryAttribute == NULL;
|
||||
if (entryAttribute == NULL) {
|
||||
entryAttribute = _AddStringAttribute(
|
||||
B_HPKG_ATTRIBUTE_ID_DIRECTORY_ENTRY, fileName);
|
||||
}
|
||||
|
||||
Stacker<Attribute> entryAttributeStacker(fTopAttribute, entryAttribute);
|
||||
|
||||
if (isNewEntry) {
|
||||
// add stat data
|
||||
if (fileType != B_HPKG_DEFAULT_FILE_TYPE)
|
||||
_AddAttribute(B_HPKG_ATTRIBUTE_ID_FILE_TYPE, fileType);
|
||||
@ -1640,6 +1646,7 @@ PackageWriterImpl::_AddEntry(int dirFD, Entry* entry, const char* fileName,
|
||||
path[bytesRead] = '\0';
|
||||
_AddStringAttribute(B_HPKG_ATTRIBUTE_ID_SYMLINK_PATH, path);
|
||||
}
|
||||
}
|
||||
|
||||
// add attributes
|
||||
if (DIR* attrDir = fs_fopen_attr_dir(fd)) {
|
||||
|
Loading…
Reference in New Issue
Block a user