From b9b06174afca99d7fe544940b950a7323631271a Mon Sep 17 00:00:00 2001 From: Sergey Katunin Date: Mon, 12 Jan 2026 12:57:40 +0000 Subject: viewproperties: remove temp file after loading defaultConfig It turns out that since f6c97d52220be9bd996b71309051e56ff7aa1834 a temp file is created here with each `save()` call for this default config, which is not deleted later. In another place where `defaultProperties()` is called for `m_node`, the file is deleted in the destructor of this class. But it is not deleted here. So, remove temp file after loading defaultConfig or it will create temp file on each save() operation in /tmp folder. Also keep the global/.directory file when xattr isn't supported. BUG: 510500 --- src/views/viewproperties.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/views/viewproperties.cpp') diff --git a/src/views/viewproperties.cpp b/src/views/viewproperties.cpp index 8bf3b2531..8be3d408e 100644 --- a/src/views/viewproperties.cpp +++ b/src/views/viewproperties.cpp @@ -73,6 +73,7 @@ ViewPropertySettings *ViewProperties::loadProperties(const QString &folderPath) // load from metadata const QString viewPropertiesString = metadata.attribute(QStringLiteral("kde.fm.viewproperties#1")); if (viewPropertiesString.isEmpty()) { + QFile::remove(tempFile->fileName()); return nullptr; } // load view properties from xattr to temp file then loads into ViewPropertySettings @@ -532,6 +533,16 @@ void ViewProperties::save() const auto items = m_node->items(); const auto defaultConfig = defaultProperties(); + + auto cleanupDefaultConfig = qScopeGuard([defaultConfig] { + // Usually it should be a temporary file, but it can be '.directory', + // if we read this file from the 'global' directory .directory file it means it did not support attributes, + // then keep the '.directory' file from 'global' here, otherwise we can remove it. + if (!defaultConfig->config()->name().endsWith(ViewPropertiesFileName)) { + QFile::remove(defaultConfig->config()->name()); + } + }); + bool allDefault = true; for (const auto item : items) { if (item->name() == "Timestamp") { -- cgit v1.3