SVN commit 1023836 by dfaure: Forwardport: in case of "disk full", return an error instead of removing the existing config file. Testcase: dd if=/dev/zero of=image count=200 ; mkfs.ext2 image ; mkdir mntpt ; sudo mount image mntpt -o loop -t ext2 cd mntpt ; sudo chown -R $UID . ; dd if=/dev/zero of=make_it_full kwriteconfig --file $PWD/outfile --key MyKey TheValue2 M +5 -0 kconfig.cpp M +7 -0 kconfigini.cpp --- trunk/KDE/kdelibs/kdecore/config/kconfig.cpp #1023835:1023836 @@ -280,6 +280,7 @@ return theMap; } +// TODO KDE5: return a bool value void KConfig::sync() { Q_D(KConfig); @@ -325,6 +326,8 @@ } if (!tmp->writeConfig(utf8Locale, d->entryMap, KConfigBackend::WriteGlobal, d->componentData)) { d->bDirty = true; + // TODO KDE5: return false? (to tell the app that writing wasn't possible, e.g. + // config file is immutable or disk full) } if (tmp->isLocked()) { tmp->unlock(); @@ -334,6 +337,8 @@ if (writeLocals) { if (!d->mBackend->writeConfig(utf8Locale, d->entryMap, KConfigBackend::WriteOptions(), d->componentData)) { d->bDirty = true; + // TODO KDE5: return false? (to tell the app that writing wasn't possible, e.g. + // config file is immutable or disk full) } } if (d->mBackend->isLocked()) { --- trunk/KDE/kdelibs/kdecore/config/kconfigini.cpp #1023835:1023836 @@ -435,6 +435,13 @@ file.setTextModeEnabled(true); // to get eol translation writeEntries(locale, file, writeMap); + if (!file.flush()) { + // Couldn't write. Disk full? + kWarning() << "Couldn't write" << filePath() << ". Disk full?"; + file.abort(); + return false; + } + if (!file.size() && (fileMode == (QFile::ReadUser | QFile::WriteUser))) { // File is empty and doesn't have special permissions: delete it. file.abort();