Commit 1bd3cde0 authored by Max Kellermann's avatar Max Kellermann

playlist: fix stored playlist modifications with absolute paths

When save_absolute_paths_in_playlists was enabled in mpd.conf, MPD broke all playlists when manipulated using the "playlistdelete" command. The reason was that map_directory_child_fs() was used, which doesn't accept slashes in the file name. Use the new map_uri_fs() function instead.
parent a94e59ca
...@@ -84,13 +84,23 @@ rmp2amp_r(char *dst, const char *rel_path) ...@@ -84,13 +84,23 @@ rmp2amp_r(char *dst, const char *rel_path)
} }
const char * const char *
map_uri_fs(const char *uri, char *buffer)
{
assert(uri != NULL);
assert(*uri != '/');
assert(buffer != NULL);
return rmp2amp_r(buffer, utf8_to_fs_charset(buffer, uri));
}
const char *
map_directory_fs(const struct directory *directory, char *buffer) map_directory_fs(const struct directory *directory, char *buffer)
{ {
const char *dirname = directory_get_path(directory); const char *dirname = directory_get_path(directory);
if (isRootDirectory(dirname)) if (isRootDirectory(dirname))
return music_dir; return music_dir;
return rmp2amp_r(buffer, utf8_to_fs_charset(buffer, dirname)); return map_uri_fs(dirname, buffer);
} }
const char * const char *
......
...@@ -33,6 +33,14 @@ void mapper_init(void); ...@@ -33,6 +33,14 @@ void mapper_init(void);
void mapper_finish(void); void mapper_finish(void);
/** /**
* Determines the absolute file system path of a relative URI. This
* is basically done by converting the URI to the file system charset
* and prepending the music directory.
*/
const char *
map_uri_fs(const char *uri, char *buffer);
/**
* Determines the file system path of a directory object. * Determines the file system path of a directory object.
* *
* @param directory the directory object * @param directory the directory object
......
...@@ -48,7 +48,7 @@ playlist_print_uri(FILE *file, const char *uri) ...@@ -48,7 +48,7 @@ playlist_print_uri(FILE *file, const char *uri)
if (playlist_saveAbsolutePaths && !isRemoteUrl(uri) && if (playlist_saveAbsolutePaths && !isRemoteUrl(uri) &&
uri[0] != '/') uri[0] != '/')
s = map_directory_child_fs(db_get_root(), uri, tmp); s = map_uri_fs(uri, tmp);
else else
s = utf8_to_fs_charset(tmp, uri); s = utf8_to_fs_charset(tmp, uri);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment