scanner: Clean up non-destructive rescan
Fix several issues with the non-destructive rescan functionality. Most of these issues also affected inotify scanning as well. These include annoying debug messages, adding album art for files that we aren't supposed to be scanning anyway, incrementing the UpdateID when no changes were made to the database, and other smaller issues.
This commit is contained in:
47
playlist.c
47
playlist.c
@ -45,6 +45,9 @@ insert_playlist(const char *path, const char *name)
|
||||
char *objname;
|
||||
char type[4];
|
||||
|
||||
if (stat(path, &file) != 0)
|
||||
return -1;
|
||||
|
||||
strncpyt(type, strrchr(name, '.')+1, 4);
|
||||
|
||||
if( start_plist(path, NULL, &file, NULL, type) != 0 )
|
||||
@ -62,28 +65,26 @@ insert_playlist(const char *path, const char *name)
|
||||
DPRINTF(E_WARN, L_SCANNER, "Bad playlist [%s]\n", path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
objname = strdup(name);
|
||||
strip_ext(objname);
|
||||
matches = sql_get_int_field(db, "SELECT count(*) from PLAYLISTS where NAME = '%q'", objname);
|
||||
if (matches > 0)
|
||||
{
|
||||
char *newname;
|
||||
xasprintf(&newname, "%s(%d)", objname, matches);
|
||||
strip_ext(newname);
|
||||
free(objname);
|
||||
objname = newname;
|
||||
}
|
||||
|
||||
DPRINTF(E_DEBUG, L_SCANNER, "Playlist %s contains %d items\n", objname, items);
|
||||
|
||||
matches = sql_get_int_field(db, "SELECT count(*) from PLAYLISTS where NAME = '%q'", objname);
|
||||
if( matches > 0 )
|
||||
{
|
||||
sql_exec(db, "INSERT into PLAYLISTS"
|
||||
" (NAME, PATH, ITEMS) "
|
||||
"VALUES"
|
||||
" ('%q(%d)', '%q', %d)",
|
||||
objname, matches, path, items);
|
||||
}
|
||||
else
|
||||
{
|
||||
sql_exec(db, "INSERT into PLAYLISTS"
|
||||
" (NAME, PATH, ITEMS) "
|
||||
"VALUES"
|
||||
" ('%q', '%q', %d)",
|
||||
objname, path, items);
|
||||
}
|
||||
|
||||
sql_exec(db, "INSERT into PLAYLISTS"
|
||||
" (NAME, PATH, ITEMS, TIMESTAMP) "
|
||||
"VALUES"
|
||||
" ('%q', '%q', %d, %lld)",
|
||||
objname, path, items, (long long)file.st_mtime);
|
||||
free(objname);
|
||||
return 0;
|
||||
}
|
||||
@ -125,6 +126,12 @@ fill_playlists(void)
|
||||
int64_t plID, detailID;
|
||||
char sql_buf[] = "SELECT ID, NAME, PATH from PLAYLISTS where ITEMS > FOUND";
|
||||
|
||||
if( GETFLAG(NO_PLAYLIST_MASK) )
|
||||
{
|
||||
DPRINTF(E_WARN, L_SCANNER, "Playlist creation disabled\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
DPRINTF(E_WARN, L_SCANNER, "Parsing playlists...\n");
|
||||
|
||||
if( sql_get_table(db, sql_buf, &result, &rows, NULL) != SQLITE_OK )
|
||||
@ -168,7 +175,7 @@ fill_playlists(void)
|
||||
{
|
||||
//DEBUG DPRINTF(E_DEBUG, L_SCANNER, "%d: already in database\n", plist.track);
|
||||
found++;
|
||||
freetags(&plist);
|
||||
freetags(&plist);
|
||||
continue;
|
||||
}
|
||||
if( last_dir )
|
||||
@ -248,7 +255,7 @@ found:
|
||||
goto retry;
|
||||
}
|
||||
}
|
||||
freetags(&plist);
|
||||
freetags(&plist);
|
||||
}
|
||||
if( last_dir )
|
||||
{
|
||||
|
Reference in New Issue
Block a user