mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-27 06:33:21 -05:00
Handle empty files table when upgrading from schema v11 -> v12
This commit is contained in:
parent
7984b4baea
commit
54c5314712
11
src/db.c
11
src/db.c
@ -4370,6 +4370,10 @@ db_upgrade_v12(void)
|
||||
goto out_fclose;
|
||||
}
|
||||
|
||||
if (sb.st_size == 0)
|
||||
dump = NULL;
|
||||
else
|
||||
{
|
||||
dump = mmap(NULL, sb.st_size, PROT_READ, MAP_SHARED, fd, 0);
|
||||
if (dump == MAP_FAILED)
|
||||
{
|
||||
@ -4378,6 +4382,7 @@ db_upgrade_v12(void)
|
||||
ret = -1;
|
||||
goto out_fclose;
|
||||
}
|
||||
}
|
||||
|
||||
/* Move old table out of the way */
|
||||
DPRINTF(E_LOG, L_DB, "Moving old files table out of the way...\n");
|
||||
@ -4410,6 +4415,8 @@ db_upgrade_v12(void)
|
||||
/* Reload dump */
|
||||
DPRINTF(E_LOG, L_DB, "Reloading new files table...\n");
|
||||
|
||||
if (dump)
|
||||
{
|
||||
ret = sqlite3_exec(hdl, dump, NULL, NULL, &errmsg);
|
||||
if (ret != SQLITE_OK)
|
||||
{
|
||||
@ -4420,6 +4427,7 @@ db_upgrade_v12(void)
|
||||
ret = -1;
|
||||
goto out_munmap;
|
||||
}
|
||||
}
|
||||
|
||||
/* Delete old files table */
|
||||
DPRINTF(E_LOG, L_DB, "Deleting old files table...\n");
|
||||
@ -4434,8 +4442,11 @@ db_upgrade_v12(void)
|
||||
}
|
||||
|
||||
out_munmap:
|
||||
if (dump)
|
||||
{
|
||||
if (munmap(dump, sb.st_size) < 0)
|
||||
DPRINTF(E_LOG, L_DB, "Could not unmap dump file: %s\n", strerror(errno));
|
||||
}
|
||||
|
||||
out_fclose:
|
||||
fclose(fp);
|
||||
|
Loading…
x
Reference in New Issue
Block a user