Summary: | KSaveFile: Unable to save file (777 permission) when the directory have 444 | ||
---|---|---|---|
Product: | [Unmaintained] kdelibs | Reporter: | Emmanuel Lepage Vallée <emmanuel.lepage> |
Component: | kdecore | Assignee: | kdelibs bugs <kdelibs-bugs> |
Status: | RESOLVED FIXED | ||
Severity: | major | CC: | adaptee, christoph, deri, elektorronikci, faure, kirill.bogdanenko, retratserif, travneff |
Priority: | NOR | ||
Version: | Git | ||
Target Milestone: | --- | ||
Platform: | Compiled Sources | ||
OS: | Linux | ||
Latest Commit: | http://commits.kde.org/kate/2aaf9df6582f3be1c6eefd857f9c5f8f2d95a93b | Version Fixed In: | 4.10.3 |
Sentry Crash Report: |
Description
Emmanuel Lepage Vallée
2012-12-31 04:04:58 UTC
This is because we use KSaveFile in Kate::TextBuffer::save(): KSaveFile saveFile (filename); if (!saveFile.open()) return false; KSaveFile first saves under a different name, and finally renames on successful safe. Obviously, since the directory owner is root with permissions rwxr-xr-x, the temporary file cannot be created. Possible solutions: 1. KSaveFile should handle this special case (save to another folder, then move; or overwrite directly) 2. Kate Part needs to work around this. (In reply to comment #1) > Possible solutions: > 1. KSaveFile should handle this special case (save to another folder, then > move; or overwrite directly) > 2. Kate Part needs to work around this. Why not to use /var/tmp/kdecache-$USER directory for temporary file and then overwrite the original file from it? There is also another problem with it, described in this bugreport: https://bugs.kde.org/show_bug.cgi?id=316234 >Why not to use /var/tmp/kdecache-$USER directory for temporary file and then overwrite the original file from it?
/tmp is not on the same device, so saving it there by default would end up requireing copies done to the original directory. A power loss during this would risk damaging date. A "move" operation, doesn't copy content, it just change the pointer. I guess save&move in the right directory is right, but not perfect.
Emmanuel is correct: Saving to tmp may be on another device. In that case, we could directly overwrite the file as well, since whether Kate or the cp-process damages the data does not make a difference... *** Bug 316234 has been marked as a duplicate of this bug. *** OK, implemented "overwrite directly", as a fallback solution for this to work. https://codereview.qt-project.org/52059 Git commit 4c59b6a716ca750e024b910f28e0263d07dae2f1 by David Faure. Committed on 04/04/2013 at 19:53. Pushed by dfaure into branch 'KDE/4.10'. KSaveFile: add setDirectWriteFallback(). This is a backport of https://codereview.qt-project.org/52059 which does the same in QSaveFile for Qt 5.1 M +48 -26 kdecore/io/ksavefile.cpp M +34 -0 kdecore/io/ksavefile.h M +84 -0 kdecore/tests/ksavefiletest.cpp M +3 -0 kdecore/tests/ksavefiletest.h http://commits.kde.org/kdelibs/4c59b6a716ca750e024b910f28e0263d07dae2f1 Git commit 2aaf9df6582f3be1c6eefd857f9c5f8f2d95a93b by Christoph Cullmann. Committed on 04/04/2013 at 22:42. Pushed by cullmann into branch 'master'. allow fallback for ksavefile allow save in dirs without write rights M +13 -0 part/buffer/katetextbuffer.cpp http://commits.kde.org/kate/2aaf9df6582f3be1c6eefd857f9c5f8f2d95a93b *** Bug 320142 has been marked as a duplicate of this bug. *** *** Bug 318462 has been marked as a duplicate of this bug. *** |