Skip to content

Commit f3c925a

Browse files
committed
Few more xattr settings at the right time
1 parent eb5d08a commit f3c925a

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/plugins/vfs/xattr/vfs_xattr.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ void VfsXAttr::startImpl(const VfsSetupParams &params)
119119
}
120120
} else {
121121
// owner is set. See if it is us
122-
const auto o = QString::fromUtf8(*owner);
122+
const auto o = QString::fromUtf8(owner.get());
123123
if (o == xattrOwnerString()) {
124124
// all good
125125
} else {
@@ -155,7 +155,7 @@ PlaceHolderAttribs VfsXAttr::placeHolderAttributes(const QString& path)
155155
auto xattr = [](const QString& p, const QString& name) {
156156
const auto value = xattr::get(p, name);
157157
if (value) {
158-
return QString::fromUtf8(*value);
158+
return QString::fromUtf8(value.get());
159159
} else {
160160
return QString();
161161
}
@@ -206,20 +206,28 @@ OCC::Result<OCC::Vfs::ConvertToPlaceholderResult, QString> VfsXAttr::updateMetad
206206
}
207207
addPlaceholderAttribute(localPath, actionXAttrName, QStringLiteral("dehydrate"));
208208
addPlaceholderAttribute(localPath, stateXAttrName, QStringLiteral("virtual"));
209+
addPlaceholderAttribute(localPath, fileSizeXAttrName, QString::number(syncItem._size));
209210
} else if (syncItem._type == ItemTypeVirtualFileDownload) {
210211
addPlaceholderAttribute(localPath, actionXAttrName, QStringLiteral("hydrate"));
211212
// file gets downloaded and becomes a normal file, the xattr gets removed
212213
xattr::remove(localPath, stateXAttrName);
214+
xattr::remove(localPath, fileSizeXAttrName);
213215
} else if (syncItem._type == ItemTypeVirtualFile) {
214216
qCDebug(lcVfsXAttr) << "updateMetadata for virtual file " << syncItem._type;
215217
addPlaceholderAttribute(localPath, stateXAttrName, QStringLiteral("virtual"));
218+
addPlaceholderAttribute(localPath, fileSizeXAttrName, QString::number(syncItem._size));
219+
} else if (syncItem._type == ItemTypeFile) {
220+
qCDebug(lcVfsXAttr) << "updateMetadata for normal file " << syncItem._type;
221+
xattr::remove(localPath, fileSizeXAttrName);
222+
} else if (syncItem._type == ItemTypeDirectory) {
223+
qCDebug(lcVfsXAttr) << "updateMetadata for directory" << syncItem._type;
216224
} else {
217225
qCDebug(lcVfsXAttr) << "Unexpected syncItem Type" << syncItem._type;
226+
Q_UNREACHABLE();
218227
}
219228

220229
FileSystem::setModTime(localPath, syncItem._modtime);
221230

222-
addPlaceholderAttribute(localPath, fileSizeXAttrName, QString::number(syncItem._size));
223231
addPlaceholderAttribute(localPath, fileidXAttrName, QString::fromUtf8(syncItem._fileId));
224232
addPlaceholderAttribute(localPath, etagXAttrName, syncItem._etag);
225233

@@ -257,6 +265,7 @@ void VfsXAttr::slotHydrateJobFinished()
257265
qCInfo(lcVfsXAttr) << u"Removing extended file attribute state failed for" << targetPath;
258266
}
259267
ok = ok && xattr::remove(targetPath, actionXAttrName);
268+
ok = ok && xattr::remove(targetPath, fileSizeXAttrName);
260269
if (!ok) {
261270
qCInfo(lcVfsXAttr) << u"Removing extended file attribute action failed for" << targetPath;
262271
}

0 commit comments

Comments
 (0)