GNOME Bugzilla – Bug 629301
.goutputstream files left behind when cancelling I/O
Last modified: 2012-12-10 16:06:32 UTC
As described in a mailing list post[1], and experienced with libfolks[2], GIO leaves behind .goutputstream-* files when cancelling an I/O operation. In libfolks, this operation is g_file_replace_contents_async(), but the mailing list post I found says it also happens for g_file_copy(). [1]: http://mail.gnome.org/archives/gvfs-list/2009-April/msg00008.html [2]: https://bugzilla.gnome.org/show_bug.cgi?id=629084#c4
Confirmed by various cases reported there. https://bugs.launchpad.net/glib/+bug/984785 ~$ dpkg -S libgio* glib-networking: /usr/lib/x86_64-linux-gnu/gio/modules/libgiognomeproxy.so libglibmm-2.4-1c2a: /usr/lib/x86_64-linux-gnu/libgiomm-2.4.so.1 libglib2.0-0: /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0 glib-networking: /usr/lib/x86_64-linux-gnu/gio/modules/libgiognutls.so libglib2.0-0: /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.3200.3 libglibmm-2.4-1c2a: /usr/lib/x86_64-linux-gnu/libgiomm-2.4.so.1.3.0 gvfs: /usr/lib/x86_64-linux-gnu/gio/modules/libgioremote-volume-monitor.so glib-networking: /usr/lib/x86_64-linux-gnu/gio/modules/libgiolibproxy.so ~$ apt-cache policy gvfs gvfs: Installed: 1.12.1-0ubuntu1 Candidate: 1.12.1-0ubuntu1 Version table: *** 1.12.1-0ubuntu1 0 500 http://archive.ubuntu.com/ubuntu/ precise/main amd64 Packages 100 /var/lib/dpkg/status
What we really want here is a method to tell the kernel/filesystem "these are temporary", and ensure that they're cleaned up on say the next reboot. That way we even handle the process crashing. Cleaning up on cancellation though is obviously useful to do as well.
*** Bug 687344 has been marked as a duplicate of this bug. ***
I'm dealing with this issue as well. I'm using Python on my application (Browse[1], from the OLPC / Sugar project) I found that downloading a file using WebKit.WebView and handling 'mime-type-policy-decision-requested' and then the 'download-request' signals WebKit leaves a '.goutputstream-*' file inside the directory where is save the file (set by 'set_destination_uri' function). (After opening the script you have to click on "21021o1.zd" link to start the download) On the other hand, if I use WebKit.NetworkRequest and WebKit.Download I don't see any '.goutputstream-*' after cancelling the download process. I'm attaching both examples, one that uses WebKit.WebView and the other that uses WebKit.NetworkRequest to see the differences. [1] http://git.sugarlabs.org/browse
Created attachment 228239 [details] Test case using WebKit.Download
Created attachment 228240 [details] Test case using WebKit.WebView
Created attachment 228379 [details] [review] gio: Don't leak the temp file when g_file_replace() fails or is cancelled If the temp file still exists at the end of the close operation, unlink it. ==== Improved version of Carlos's patch from the other bug, plus a test case
Thanks Dan!
(In reply to comment #7) > Created an attachment (id=228379) [details] [review] > gio: Don't leak the temp file when g_file_replace() fails or is cancelled I tried this patch with my test case (using WebKit.WebView) and the .goutputstream is still there after cancelling the downloading process. Here you have the log of "inotifywait": $ inotifywait --monitor /tmp/ | grep -v vte /tmp/ CREATE .goutputstream-9Y7FNW /tmp/ OPEN .goutputstream-9Y7FNW /tmp/ ATTRIB .goutputstream-9Y7FNW /tmp/ ATTRIB .goutputstream-9Y7FNW /tmp/ MODIFY .goutputstream-9Y7FNW (...) /tmp/ MODIFY .goutputstream-9Y7FNW /tmp/ CLOSE_WRITE,CLOSE .goutputstream-9Y7FNW With the script that uses WebKit.Download I get this output: /tmp/ CREATE .goutputstream-TM1KNW /tmp/ OPEN .goutputstream-TM1KNW /tmp/ ATTRIB .goutputstream-TM1KNW /tmp/ ATTRIB .goutputstream-TM1KNW /tmp/ MODIFY .goutputstream-TM1KNW (...) /tmp/ MODIFY .goutputstream-TM1KNW /tmp/ CREATE 21021o1.zd~ /tmp/ MOVED_FROM .goutputstream-TM1KNW /tmp/ MOVED_TO 21021o1.zd /tmp/ CLOSE_WRITE,CLOSE 21021o1.zd Thanks,
(In reply to comment #9) > I tried this patch with my test case (using WebKit.WebView) and the > .goutputstream is still there after cancelling the downloading process. That's apparently because the GLocalFileOutputStream never gets closed in that case; I don't know if that's a bug in your script or in WebKit.
I confirm the patch fixes the problem for me.
Attachment 228379 [details] pushed as afdb2ab - gio: Don't leak the temp file when g_file_replace() fails or is cancelled