"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "playlist.c" between
minidlna-1.2.0.tar.gz and minidlna-1.2.1.tar.gz

About: ReadyMedia (formerly known as MiniDLNA) is a simple media server software, with the aim of being fully compliant with DLNA/UPnP-AV clients.

playlist.c  (minidlna-1.2.0):playlist.c  (minidlna-1.2.1)
skipping to change at line 40 skipping to change at line 40
#include "tagutils/tagutils.h" #include "tagutils/tagutils.h"
#include "upnpglobalvars.h" #include "upnpglobalvars.h"
#include "scanner.h" #include "scanner.h"
#include "metadata.h" #include "metadata.h"
#include "utils.h" #include "utils.h"
#include "sql.h" #include "sql.h"
#include "log.h" #include "log.h"
int int
insert_playlist(const char * path, char * name) insert_playlist(const char *path, const char *name)
{ {
struct song_metadata plist; struct song_metadata plist;
struct stat file; struct stat file;
int items = 0, matches, ret; int items = 0, matches, ret;
char *objname;
char type[4]; char type[4];
if (stat(path, &file) != 0)
return -1;
strncpyt(type, strrchr(name, '.')+1, 4); strncpyt(type, strrchr(name, '.')+1, 4);
if( start_plist(path, NULL, &file, NULL, type) != 0 ) if( start_plist(path, NULL, &file, NULL, type) != 0 )
{ {
DPRINTF(E_WARN, L_SCANNER, "Bad playlist [%s]\n", path); DPRINTF(E_WARN, L_SCANNER, "Bad playlist [%s]\n", path);
return -1; return -1;
} }
while( (ret = next_plist_track(&plist, &file, NULL, type)) == 0 ) while( (ret = next_plist_track(&plist, &file, NULL, type)) == 0 )
{ {
items++; items++;
freetags(&plist); freetags(&plist);
} }
if( ret == 2 ) // Bad playlist -- contains binary characters if( ret == 2 ) // Bad playlist -- contains binary characters
{ {
DPRINTF(E_WARN, L_SCANNER, "Bad playlist [%s]\n", path); DPRINTF(E_WARN, L_SCANNER, "Bad playlist [%s]\n", path);
return -1; return -1;
} }
strip_ext(name);
DPRINTF(E_DEBUG, L_SCANNER, "Playlist %s contains %d items\n", name, item
s);
matches = sql_get_int_field(db, "SELECT count(*) from PLAYLISTS where NAM objname = strdup(name);
E = '%q'", name); strip_ext(objname);
if( matches > 0 ) matches = sql_get_int_field(db, "SELECT count(*) from PLAYLISTS where NAM
{ E = '%q'", objname);
sql_exec(db, "INSERT into PLAYLISTS" if (matches > 0)
" (NAME, PATH, ITEMS) " {
"VALUES" char *newname;
" ('%q(%d)', '%q', %d)", xasprintf(&newname, "%s(%d)", objname, matches);
name, matches, path, items); strip_ext(newname);
} free(objname);
else objname = newname;
{ }
sql_exec(db, "INSERT into PLAYLISTS"
" (NAME, PATH, ITEMS) " DPRINTF(E_DEBUG, L_SCANNER, "Playlist %s contains %d items\n", objname, i
"VALUES" tems);
" ('%q', '%q', %d)",
name, 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; return 0;
} }
static unsigned int static unsigned int
gen_dir_hash(const char *path) gen_dir_hash(const char *path)
{ {
char dir[PATH_MAX], *base; char dir[PATH_MAX], *base;
int len; int len;
strncpy(dir, path, sizeof(dir)); strncpy(dir, path, sizeof(dir));
skipping to change at line 124 skipping to change at line 128
char **result; char **result;
char *plpath, *plname, *fname, *last_dir; char *plpath, *plname, *fname, *last_dir;
unsigned int hash, last_hash = 0; unsigned int hash, last_hash = 0;
char class[] = "playlistContainer"; char class[] = "playlistContainer";
struct song_metadata plist; struct song_metadata plist;
struct stat file; struct stat file;
char type[4]; char type[4];
int64_t plID, detailID; int64_t plID, detailID;
char sql_buf[] = "SELECT ID, NAME, PATH from PLAYLISTS where ITEMS > FOUN D"; char sql_buf[] = "SELECT ID, NAME, PATH from PLAYLISTS where ITEMS > FOUN D";
if( GETFLAG(NO_PLAYLIST_MASK) )
{
DPRINTF(E_WARN, L_SCANNER, "Playlist creation disabled\n");
return 0;
}
DPRINTF(E_WARN, L_SCANNER, "Parsing playlists...\n"); DPRINTF(E_WARN, L_SCANNER, "Parsing playlists...\n");
if( sql_get_table(db, sql_buf, &result, &rows, NULL) != SQLITE_OK ) if( sql_get_table(db, sql_buf, &result, &rows, NULL) != SQLITE_OK )
return -1; return -1;
if( !rows ) if( !rows )
goto done; goto done;
rows++; rows++;
for( i=3; i<rows*3; i++ ) for( i=3; i<rows*3; i++ )
{ {
skipping to change at line 167 skipping to change at line 177
plpath = dirname(plpath); plpath = dirname(plpath);
found = 0; found = 0;
while( next_plist_track(&plist, &file, NULL, type) == 0 ) while( next_plist_track(&plist, &file, NULL, type) == 0 )
{ {
hash = gen_dir_hash(plist.path); hash = gen_dir_hash(plist.path);
if( sql_get_int_field(db, "SELECT 1 from OBJECTS where OB JECT_ID = '%s$%llX$%d'", if( sql_get_int_field(db, "SELECT 1 from OBJECTS where OB JECT_ID = '%s$%llX$%d'",
MUSIC_PLIST_ID, plID, plist.track) == 1 ) MUSIC_PLIST_ID, plID, plist.track) == 1 )
{ {
//DEBUG DPRINTF(E_DEBUG, L_SCANNER, "%d: already in database\n", plist.track); //DEBUG DPRINTF(E_DEBUG, L_SCANNER, "%d: already in database\n", plist.track);
found++; found++;
freetags(&plist); freetags(&plist);
continue; continue;
} }
if( last_dir ) if( last_dir )
{ {
if( hash == last_hash ) if( hash == last_hash )
{ {
fname = basename(plist.path); fname = basename(plist.path);
detailID = sql_get_int_field(db, "SELECT ID from DETAILS where PATH = '%q/%q'", last_dir, fname); detailID = sql_get_int_field(db, "SELECT ID from DETAILS where PATH = '%q/%q'", last_dir, fname);
} }
else else
skipping to change at line 247 skipping to change at line 257
{ {
fname = modifyString(fname, "\\", "/", 1) ; fname = modifyString(fname, "\\", "/", 1) ;
goto retry; goto retry;
} }
else if( (fname = strchr(fname, '/')) ) else if( (fname = strchr(fname, '/')) )
{ {
fname++; fname++;
goto retry; goto retry;
} }
} }
freetags(&plist); freetags(&plist);
} }
if( last_dir ) if( last_dir )
{ {
sqlite3_free(last_dir); sqlite3_free(last_dir);
last_dir = NULL; last_dir = NULL;
} }
sql_exec(db, "UPDATE PLAYLISTS set FOUND = %d where ID = %lld", f ound, plID); sql_exec(db, "UPDATE PLAYLISTS set FOUND = %d where ID = %lld", f ound, plID);
} }
done: done:
sqlite3_free_table(result); sqlite3_free_table(result);
 End of changes. 8 change blocks. 
25 lines changed or deleted 35 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)