GNOME Bugzilla – Bug 429107
Beagle-live error when trying to open files or folders
Last modified: 2007-09-27 09:48:56 UTC
Please describe the problem: When I use the deskbar-applet Beagle Live handler, search results return fine. The trouble is when I try to open a file or folder. When I try to open a folder, it returns this error: Couldn't find "/file:/home/xitij/School". Please check the spelling and try again. When I try to open a file 'q.pdf', it returns: Cannot show URL: 'file://file%3A///home/xitij/School/3A%2520Work%2520Term%2520Report'. Note that Beagle's own search tool works perfectly fine. Steps to reproduce: 1. Enter a query for a file or folder. 2. Click the returned result. Actual results: An error message as described above. Expected results: For it to actually open the file or folder. Does this happen every time? Yes. Other information: I've isolated this issue down to Lines 104 to 112 in beagle-live.py in /usr/lib/deskbar-applet/handlers/. "File" : { "name" : ("beagle:ExactFilename",), "action": lambda d: url_show_file("file://"+d["uri"]), "icon" : "stock_new", #translators: This is a file. "description": _("Open %s") % "<b>%(name)s</b>", "snippet": True, "category": "files", }, The 3rd line above, where the string 'file://' is pre-pended to the search result seems to be the issue. I tried removing this string, but then got the error: Cannot execute program '/path/to/the/(The file I wanted)'. Same for folders. Please fix this ASAP, I really love using this tool. It's useless to me without this now.
This was caused by http://svn.gnome.org/viewcvs/deskbar-applet/trunk/deskbar/handlers/beagle-live.py?r1=1109&r2=1178 I'm looking into it
The patch above was applied to fix bug 411209 btw
I suppose you already know this, but I thought I'd mention that as with the previous bug I think this only applies to filenames with spaces in.
i've narrowed down the problem and sort of fixed it as well. The problem seems to lie in the Utils.py file in the url_show_file(url) function. It seems that even if you put url_show_file(d["uri"]) instead of url_show_file("file://"+d["uri"]) the file:// prefix is added therefore in Utils.py, line 125 is not needed and you can simply pass 'url' into gnomevfs.url_show()
Based on Luke's idea, changing: url_show_file("file://"+d["uri"]) to: url_show(d["uri"]) seems to fix the issue. I've tested file names containing spaces as well as file names containing unicode characters and it worked for me®
*** Bug 411209 has been marked as a duplicate of this bug. ***
Rüdiger's fix works--at least for now--but I don't think it should be used. Let me elaborate. Firstly, I suggested adding the "file://" to fix Bug 411209. Either I'm mad, or at the time, d["uri"] didn't include "file://". Anyway, now ["uri"] does include "file://", which I guess might be due to a change in Beagle's behaviour (?). The current problem with d["uri"] is that it's URL-encoded, which I'm guessing it shouldn't be, as there's also the parameter d["escaped_uri"]. You can verify that uri is URL-encoded in beagle-live.py by changing the file open function to: def url_log_file(d): f = open("beaglelog", "a") f.write("%s\n" % (d["uri"],)) f.close() So, I recommend using escaped_uri instead of uri, because it's clear that it's escaped. If we were to use uri and it isn't meant to be escaped, some bug fix later might cause it to be unescaped, causing problems here again. Secondly, there's an advantage to using url_show_file as opposed to url_show: the file gets added to the recent files list. We can't use url_show_file as is, though, because it expects an unescaped URL. So in comments 3 and 4 of Bug 411209, I suggested the ugly fix of adding an extra parameter to url_show_file, indicating whether the URL's escaped. I'll repost it here for your convenience: In beagle-live.py, change the action to: "action": lambda d: url_show_file(d["escaped_uri"], escaped=True) And in Utils.py, the beginning of url_show_file should be: def url_show_file(url, escaped=False): try: if escaped: uri = url else: uri = gnomevfs.escape_host_and_path_string(url) gnomevfs.url_show(uri)
Just a side note, I threw together a patch based on Iain Nicol's advice in Comment #7 for Fedora, which seemed to do the trick, and pushed a new version of deskbar-applet to our devel tree. http://cvs.fedora.redhat.com/viewcvs/rpms/deskbar-applet/devel/deskbar-applet-beagle-live.patch?rev=1.1&view=auto
Without knowing that this bug existed I did exactly what Iain Nicol did. In addition, I fixed several bugs in beagle-live for 2.19.91.