From 1a813b8834f06c4b3a03fb5519cd72c713fd4cf7 Mon Sep 17 00:00:00 2001 From: Sebastian Englbrecht Date: Sat, 23 May 2026 13:27:54 +0200 Subject: viewproperties: fall back to .directory when xattr space is exhausted MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When saving view properties to extended attributes failed with NoSpace, the code cleared the xattr entry and returned without writing anything to disk. The .directory fallback file was never created, silently losing the user's view settings. Fix by copying the current settings into a file-backed KConfig pointing to .directory whenever the xattr write returns NoSpace. The copy uses KConfigGroup::copyTo per group (not KConfig::copyFrom, which replaces the entire entry map) so that unrelated groups already present in .directory — such as a [Desktop Entry] group carrying a custom folder icon — are left untouched by sync(). --- src/views/viewproperties.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/views/viewproperties.cpp') diff --git a/src/views/viewproperties.cpp b/src/views/viewproperties.cpp index c5e53586c..9cd834991 100644 --- a/src/views/viewproperties.cpp +++ b/src/views/viewproperties.cpp @@ -640,10 +640,24 @@ void ViewProperties::save() // free the space used by viewproperties from the file metadata metaData.setAttribute(MetaDataKey, QString()); qCWarning(DolphinDebug) << "could not save viewproperties to extended attributes for dir " << m_filePath << ", no space available in attributes"; + // xattr space exhausted — fall back to .directory file. + // Copy only the Dolphin-managed groups into the existing file using + // KConfigGroup::copyTo so that unrelated groups (e.g. [Desktop Entry] + // with a custom folder icon) are left untouched by sync(). + const QString settingsFile = m_filePath + QDir::separator() + ViewPropertiesFileName; + KConfig fileConfig(settingsFile, KConfig::SimpleConfig); + for (const QString &group : m_node->config()->groupList()) { + KConfigGroup srcGrp(m_node->config(), group); + KConfigGroup dstGrp(&fileConfig, group); + srcGrp.copyTo(&dstGrp); + } + if (!fileConfig.sync()) { + qCWarning(DolphinDebug) << "could not save viewproperties to .directory for" << m_filePath; + } } else { qCWarning(DolphinDebug) << "could not save viewproperties to extended attributes for dir " << m_filePath << "error:" << result; } - // keep .directory file + m_changedProps = false; return; } cleanDotDirectoryFile(); -- cgit v1.3.1