GNOME Bugzilla – Bug 615110
write file ignore encoding errors
Last modified: 2014-08-20 21:28:54 UTC
Using gedit 2.30: * open the gedit tarball ChangeLog * try saving it in ISO-8859-15 * gedit raises an encoding error the file is saved anyway with broken encoding
Just so that I don't forget before trying to fix this, the output stream does the tmp-to-original copy when closing the stream. This now happens also when there is an error in reading from the input stream. The output stream is in a perfectly fine state, and when it's closed the copy happens. From reading the output stream code, the only way to disable this is to explicitly close the stream, with a GCancellable which is in the 'cancelled' state. This might not really be the most intuitive thing to do, but at least we can fix the bug like that. The relevant part in the code is the function async_failed in gedit-gio-document-saver.c. Note that we also call this path, when closing the output stream fails. Obviously we wouldn't want to try to close it again, so we need to catch that case. In async_failed, we should preferably close the stream async, but it might need some more state keeping to implement that.
I think we can simply cancel before calling async_failed
I don't think so. The cancellable is only associated with the write process, which at that point is finished for that chunk. I admit, it was the first thing I tried too, but it doesn't work (because the stream closing is called from somewhere else , we don't explicitly close it, and doesn't receive that cancellable).
This is bug 602412
We've managed to put in a temporary fix for the problem. I'll leave the bug report open for reference if we want to add proper API for this case to gio.
This bug is referenced in the code in gtksourcefilesaver.c, no need to keep it open.