After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 629301 - .goutputstream files left behind when cancelling I/O
.goutputstream files left behind when cancelling I/O
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
unspecified
Other Linux
: Normal minor
: ---
Assigned To: gtkdev
gtkdev
: 687344 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2010-09-10 16:21 UTC by Philip Withnall
Modified: 2012-12-10 16:06 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Test case using WebKit.Download (1.62 KB, text/x-python)
2012-11-06 12:42 UTC, Manuel Kaufmann
  Details
Test case using WebKit.WebView (1.92 KB, text/x-python)
2012-11-06 12:42 UTC, Manuel Kaufmann
  Details
gio: Don't leak the temp file when g_file_replace() fails or is cancelled (7.77 KB, patch)
2012-11-07 15:40 UTC, Dan Winship
committed Details | Review

Description Philip Withnall 2010-09-10 16:21:43 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
Comment 1 sam_ 2012-08-25 18:03:24 UTC
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
Comment 2 Colin Walters 2012-08-25 18:17:13 UTC
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.
Comment 3 Dan Winship 2012-11-02 12:31:46 UTC
*** Bug 687344 has been marked as a duplicate of this bug. ***
Comment 4 Manuel Kaufmann 2012-11-06 12:41:35 UTC
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
Comment 5 Manuel Kaufmann 2012-11-06 12:42:29 UTC
Created attachment 228239 [details]
Test case using WebKit.Download
Comment 6 Manuel Kaufmann 2012-11-06 12:42:53 UTC
Created attachment 228240 [details]
Test case using WebKit.WebView
Comment 7 Dan Winship 2012-11-07 15:40:11 UTC
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
Comment 8 Carlos Garcia Campos 2012-11-08 07:32:56 UTC
Thanks Dan!
Comment 9 Manuel Kaufmann 2012-11-09 18:21:55 UTC
(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,
Comment 10 Dan Winship 2012-11-16 18:43:10 UTC
(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.
Comment 11 Carlos Garcia Campos 2012-11-17 13:24:04 UTC
I confirm the patch fixes the problem for me.
Comment 12 Dan Winship 2012-12-10 16:06:26 UTC
Attachment 228379 [details] pushed as afdb2ab - gio: Don't leak the temp file when g_file_replace() fails or is cancelled