Merge branch 'chme-mpd'

This commit is contained in:
ejurgensen 2015-06-04 21:59:06 +02:00
commit ac34ffabec
3 changed files with 46 additions and 2 deletions

View File

@ -4639,12 +4639,16 @@ db_perthread_deinit(void)
" VALUES(8, 'Purchased', 0, 'media_kind = 1024', 0, '', 0, 8);" " VALUES(8, 'Purchased', 0, 'media_kind = 1024', 0, '', 0, 8);"
*/ */
/* Rule of thumb: Will the current version of forked-daapd work with the new
* version of the database? If yes, then it is a minor upgrade, if no, then it
* is a major upgrade. In other words minor version upgrades permit downgrading
* forked-daapd after the database was upgraded. */
#define SCHEMA_VERSION_MAJOR 18 #define SCHEMA_VERSION_MAJOR 18
#define SCHEMA_VERSION_MINOR 00 #define SCHEMA_VERSION_MINOR 01
#define Q_SCVER_MAJOR \ #define Q_SCVER_MAJOR \
"INSERT INTO admin (key, value) VALUES ('schema_version_major', '18');" "INSERT INTO admin (key, value) VALUES ('schema_version_major', '18');"
#define Q_SCVER_MINOR \ #define Q_SCVER_MINOR \
"INSERT INTO admin (key, value) VALUES ('schema_version_minor', '00');" "INSERT INTO admin (key, value) VALUES ('schema_version_minor', '01');"
struct db_init_query { struct db_init_query {
char *query; char *query;
@ -5900,6 +5904,32 @@ static const struct db_init_query db_upgrade_v18_queries[] =
{ U_V18_SCVER_MINOR, "set schema_version_minor to 00" }, { U_V18_SCVER_MINOR, "set schema_version_minor to 00" },
}; };
/* Upgrade from schema v18.00 to v18.01 */
/* Change virtual_path for playlists: remove file extension
*/
#define U_V1801_UPDATE_PLAYLISTS_M3U \
"UPDATE playlists SET virtual_path = replace(virtual_path, '.m3u', '');"
#define U_V1801_UPDATE_PLAYLISTS_PLS \
"UPDATE playlists SET virtual_path = replace(virtual_path, '.pls', '');"
#define U_V1801_UPDATE_PLAYLISTS_SMARTPL \
"UPDATE playlists SET virtual_path = replace(virtual_path, '.smartpl', '');"
#define U_V1801_SCVER_MAJOR \
"UPDATE admin SET value = '18' WHERE key = 'schema_version_major';"
#define U_V1801_SCVER_MINOR \
"UPDATE admin SET value = '01' WHERE key = 'schema_version_minor';"
static const struct db_init_query db_upgrade_v1801_queries[] =
{
{ U_V1801_UPDATE_PLAYLISTS_M3U, "update table playlists" },
{ U_V1801_UPDATE_PLAYLISTS_PLS, "update table playlists" },
{ U_V1801_UPDATE_PLAYLISTS_SMARTPL, "update table playlists" },
{ U_V1801_SCVER_MAJOR, "set schema_version_major to 18" },
{ U_V1801_SCVER_MINOR, "set schema_version_minor to 01" },
};
static int static int
db_upgrade(int db_ver) db_upgrade(int db_ver)
{ {
@ -5992,6 +6022,13 @@ db_upgrade(int db_ver)
if (ret < 0) if (ret < 0)
return -1; return -1;
/* FALLTHROUGH */
case 1800:
ret = db_generic_upgrade(db_upgrade_V1801_queries, sizeof(db_upgrade_v1801_queries) / sizeof(db_upgrade_v1801_queries[0]));
if (ret < 0)
return -1;
break; break;
default: default:

View File

@ -167,6 +167,9 @@ scan_playlist(char *file, time_t mtime)
pli->path = strdup(file); pli->path = strdup(file);
snprintf(virtual_path, PATH_MAX, "/file:%s", file); snprintf(virtual_path, PATH_MAX, "/file:%s", file);
ptr = strrchr(virtual_path, '.');
if (ptr)
*ptr = '\0';
pli->virtual_path = strdup(virtual_path); pli->virtual_path = strdup(virtual_path);
ret = db_pl_add(pli, &pl_id); ret = db_pl_add(pli, &pl_id);

View File

@ -165,6 +165,7 @@ scan_smartpl(char *file, time_t mtime)
struct playlist_info *pli; struct playlist_info *pli;
int pl_id; int pl_id;
char virtual_path[PATH_MAX]; char virtual_path[PATH_MAX];
char *ptr;
int ret; int ret;
/* Fetch or create playlist */ /* Fetch or create playlist */
@ -182,6 +183,9 @@ scan_smartpl(char *file, time_t mtime)
pli->path = strdup(file); pli->path = strdup(file);
snprintf(virtual_path, PATH_MAX, "/file:%s", file); snprintf(virtual_path, PATH_MAX, "/file:%s", file);
ptr = strrchr(virtual_path, '.');
if (ptr)
*ptr = '\0';
pli->virtual_path = strdup(virtual_path); pli->virtual_path = strdup(virtual_path);
pli->type = PL_SMART; pli->type = PL_SMART;
} }