diff options
| author | Sergey Katunin <[email protected]> | 2026-01-12 12:57:40 +0000 |
|---|---|---|
| committer | Méven Car <[email protected]> | 2026-01-12 12:57:40 +0000 |
| commit | b9b06174afca99d7fe544940b950a7323631271a (patch) | |
| tree | 23c196c7eabba40d0c500001ec339649b4bd2feb /src/views | |
| parent | 6cd94cbecbbee52ae380e51671a4160272195fee (diff) | |
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
Diffstat (limited to 'src/views')
| -rw-r--r-- | src/views/viewproperties.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
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") { |
