Skip to content

Commit 0a386ae

Browse files
committed
Don't overwrite config file when it has no write permission
1 parent d779e98 commit 0a386ae

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/base/settingsstorage.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,16 @@ void SettingsStorage::readNativeSettings()
163163

164164
bool SettingsStorage::writeNativeSettings() const
165165
{
166-
std::unique_ptr<QSettings> nativeSettings = Profile::instance()->applicationSettings(m_nativeSettingsName + u"_new");
166+
const auto *profile = Profile::instance();
167+
168+
// No-op when it has no write permission
169+
if (const auto confPath = Path(profile->applicationSettings(m_nativeSettingsName)->fileName());
170+
confPath.exists() && !Utils::Fs::isWritable(confPath))
171+
{
172+
return true; // no need to retry saving
173+
}
174+
175+
std::unique_ptr<QSettings> nativeSettings = profile->applicationSettings(m_nativeSettingsName + u"_new");
167176

168177
// QSettings deletes the file before writing it out. This can result in problems
169178
// if the disk is full or a power outage occurs. Those events might occur

0 commit comments

Comments
 (0)