Menu

#357 Bug in handling of clashing playlist names.

v1.0 (example)
open
nobody
None
5
2023-08-19
2023-08-19
paul
No

The code does not appear to deal with multiple playlists of the same name (such as might occur when multiple directories are imported all of which have a playlist called "playlist").

It seems the intent was to add "(n)" to the name where "n" increments to create a unique name - playlist, then playlist(1), playlist(2) etc.

However the search is only for the clashing name, the code does not check if an earlier clash was resolved - resulting in playlist, playlist(1), playlist(1) etc.

The following patch remedies this:

--- playlist.c.orig 2023-05-31 09:25:59.000000000 +0100
+++ playlist.c  2023-08-19 20:48:02.924623329 +0100
@@ -72,7 +72,9 @@
    if (matches > 0)
    {
        char *newname;
-       xasprintf(&newname, "%s(%d)", objname, matches);
+
+       matches = sql_get_int_field(db, "SELECT count(*) from PLAYLISTS where NAME LIKE '%q(%%)'", objname);
+       xasprintf(&newname, "%s(%d)", objname, matches+1);
        strip_ext(newname);
        free(objname);
        objname = newname;

Discussion


Log in to post a comment.