Invalid export path bug
donaghhorgan opened this issue · comments
When I try to export playlists, the paths aren't composed properly, which results in an error. For example, using the plugin out of the box, the export feature tries to save a test playlist I create to:
/home/donagh/.local/share/rhythmbox/plugins/playlists_ieplaylists_import_export/New Playlist.m3u
which results in an error because there is no directory callled playlists_ieplaylists_import_export
. The correct path, I'm guessing, should be:
/home/donagh/.local/share/rhythmbox/plugins/playlists_ie/playlists_import_export/New Playlist.m3u
I think the offending line is:
conf.set_string(MY_GCONF_PREFIX+"folder",os.getcwd()+"playlists_import_export")
This should probably read something like:
conf.set_string(MY_GCONF_PREFIX+"folder", os.path.join(os.getcwd(), "playlists_import_export"))
The line seems to be in both the main plugin file and the preferences file, so it'll need to be changed in both.
Unfortunately, there's one more problem: when I edit the GConf setting manually, so that the plugin points at the correct path, the export still fails because the playlists_import_export
subdirectory doesn't exist. It would probably be best to check that the path setting is valid before saving it to GConf (you could just keep making the user pick a path until a valid one is specified). Something like
os.path.isdir(path)
would do the trick (either this, or create the directory if it doesn't exist - either would work).
hmm - I was going to say something similar :)
The gnome crowd consider the use of gconf kind of deprecated - gsettings is the preferred route.
Any thoughts going down this route instead of gconf?
I tried to do it with GSettings at first, but I just could not figure out how to install a GSettings schema with python on runtime (and not via some install script to copy an actual .xml). And about the default playlist location - yea, that's pretty bad code. I thought about it now and I'll just make the user choose when the path is empty (that will be the exact moment to issue a warning for deleting the playlists on import too). In a day or two I should get to those tasks.
Implemented GSettings with an installer