Converting a sound in "/" causes an error

Bug #1087901 reported by ideasman42
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SoundConverter
Fix Released
Critical
GautierPortet

Bug Description

If I try convert "/a.ogg" its added as "//a.ogg", then when pressing convert I get the error.

Invalid URI: '//a.mp3'

---
This is very simple to redo.

Revision history for this message
Michael Schwendt (mschwendt) wrote :

Yes, easy to reproduce.

Have had a brief look only:

ui.py add_uris() takes a list of URIs. Here a filename with "file://" prefix, so it starts with "file:///a.ogg" correctly. Further below in the same function, it splits of a "base" value where it gets wrong:

        if not base:
            base, notused = os.path.split(os.path.commonprefix(files))
        base += '/'

It here ends up with a base value "file:/" which is wrong. It then uses this base value to create a SoundFile object,

        for f in files:
            sound_file = SoundFile(f, base)

where we end up in file soundfile.py where it splits the uri into a base_path and a filename:

        if base_path:
            self.base_path = base_path
            self.filename = self.uri[len(self.base_path):]
        else:
            self.base_path, self.filename = os.path.split(self.uri)
            self.base_path += '/'

Obviously, splitting off "file:/" of "file:///a.ogg" results in "//a.ogg".

No idea why it does all that. A brute-force work-around would have been to simply replace a leading '//' from the filename, but interestingly, GStreamer then refused to open the file /a.ogg (because it's owned by root.root, of course), and the --debug output said:

Error: <b>GStreamer Error:</b>
Could not open resource for writing.
<i>(/a.ogg)</i>

Error: <b>GStreamer Error:</b>
Could not open resource for writing.
<i>(/a.ogg)</i>
Cannot set permission on '/a.wav'

Changed in soundconverter:
status: New → Confirmed
Revision history for this message
GautierPortet (kassoulet) wrote :

The problem is in "os.path.split(os.path.commonprefix(files))".
The goal is to get the base folder of all files added, so we can reproduce the arborescence elsewhere. But here, "file:///a.ogg" should have "file:///" as base folder instead of "file:". Basically, the split must work with URIs.

Revision history for this message
GautierPortet (kassoulet) wrote :

And this is because of python's os.path functions, which don't support URIs.
This is fixed by commit 701b41. Thank you for your precious help!

https://github.com/kassoulet/soundconverter/commit/701b416719b6cbca5761681abbd81babbe86a591

Changed in soundconverter:
status: Confirmed → Fix Committed
importance: Undecided → Critical
assignee: nobody → GautierPortet (kassoulet)
Revision history for this message
GautierPortet (kassoulet) wrote :

Previous fix is not enough. Don't work with different URI schemes...

Changed in soundconverter:
status: Fix Committed → Confirmed
Revision history for this message
GautierPortet (kassoulet) wrote :
Changed in soundconverter:
status: Confirmed → Fix Committed
Changed in soundconverter:
milestone: none → 2.1.0
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.