As suggested by Robert Krawitz on 2007-11-07, KPA should be smart when dealing with file I/O: As a general principle, everything that writes data really does need to check the return value from both the write and the close (the write, particularly if you're using buffered I/O, may not be synchronous), period. There are no shortcuts. You can't rely on anything else monitoring free space, and there are a lot of other reasons a write could fail (network problems, for example, if you're using a networked filesystem). Creating a bunch of zero length thumbnails is embarrassing. If writing the index.xml file has the same problem, the results could be much more serious.
For index.xml the trick could be first to write to another file in the same directory, and then move the file in place. The code for writing the XML data is in XMLDB/FileWriter.cpp (XMLDB::FileWriter::save). You would have to find a way to simulate out of hard disk (perhaps use a key ring for storing your data)
Created attachment 37596 [details] This Path will inform user if write ends not succsesful
As Jesper pointed out, especially a write error on index.xml should be taken care off. Testing running out of disk situation should be quite straight forward at least with a loop back mounting a smallish file system. Steps to create: dd if=/dev/zero of=KPhotoAlbum-test.img bs=1M count=10 sudo losetup /dev/loop0 KPhotoAlbum-test.img sudo mke2fs -c /dev/loop0 mkdir KPhotoAlbum-test-mount sudo mount /dev/loop0 KPhotoAlbum-test-mount Now just copy a couple of files to KPhotoAlbum-test-mount and start hacking. To unmount the fs and detach the loop do: sudo umount KPhotoAlbum-test-mount losetup -d /dev/oop0
(In reply to comment #3) > As Jesper pointed out, especially a write error on index.xml should be taken > care off. Testing running out of disk situation should be quite straight > forward at least with a loop back mounting a smallish file system. Steps to > create: > > dd if=/dev/zero of=KPhotoAlbum-test.img bs=1M count=10 > sudo losetup /dev/loop0 KPhotoAlbum-test.img > sudo mke2fs -c /dev/loop0 > mkdir KPhotoAlbum-test-mount > sudo mount /dev/loop0 KPhotoAlbum-test-mount > > Now just copy a couple of files to KPhotoAlbum-test-mount and start hacking. > To unmount the fs and detach the loop do: > > sudo umount KPhotoAlbum-test-mount > losetup -d /dev/oop0 Using tmpfs you can achieve this even simpler: mkdir KPhotoAlbum-test-mount sudo mount none -t tmpfs -o size=10m KPhotoAlbum-test-mount (...test stuff...) sudo umount KPhotoAlbum-test-mount
Git commit 9a55cef622459a069114fb8bb4f67977bc9717ae by Miika Turkia, on behalf of Johannes Zarl. Committed on 12/02/2012 at 21:36. Pushed by mturkia into branch 'master'. Better detection of write problems. Check results when writing zip files in XMLDB::NumberedBackup. Check results when using QFile IO in XMLDB::Filewriter and AnnotationDialog::Dialog. M +14 -2 AnnotationDialog/Dialog.cpp M +15 -3 XMLDB/FileWriter.cpp M +4 -1 XMLDB/NumberedBackup.cpp http://commits.kde.org/kphotoalbum/9a55cef622459a069114fb8bb4f67977bc9717ae