"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "scanner.c" between
minidlna-1.2.1.tar.gz and minidlna-1.3.0.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.

scanner.c  (minidlna-1.2.1):scanner.c  (minidlna-1.3.0)
skipping to change at line 65 skipping to change at line 65
#endif #endif
#ifndef AV_LOG_PANIC #ifndef AV_LOG_PANIC
#define AV_LOG_PANIC AV_LOG_FATAL #define AV_LOG_PANIC AV_LOG_FATAL
#endif #endif
int valid_cache = 0; int valid_cache = 0;
struct virtual_item struct virtual_item
{ {
int64_t objectID; int64_t objectID;
char parentID[64]; char parentID[80];
char name[256]; char name[256];
}; };
int64_t int64_t
get_next_available_id(const char *table, const char *parentID) get_next_available_id(const char *table, const char *parentID)
{ {
char *ret, *base; char *ret, *base;
int64_t objectID = 0; int64_t objectID = 0;
ret = sql_get_text_field(db, "SELECT OBJECT_ID from %s where ID = " ret = sql_get_text_field(db, "SELECT OBJECT_ID from %s where ID = "
skipping to change at line 206 skipping to change at line 206
last_camdate.name[0] = '\0'; last_camdate.name[0] = '\0';
} }
if( valid_cache && strcmp(last_camdate.name, date_taken) == 0 ) if( valid_cache && strcmp(last_camdate.name, date_taken) == 0 )
{ {
last_camdate.objectID++; last_camdate.objectID++;
//DEBUG DPRINTF(E_DEBUG, L_SCANNER, "Using last camdate i tem: %s/%s/%s/%X\n", camera, last_camdate.name, last_camdate.parentID, last_camd ate.objectID); //DEBUG DPRINTF(E_DEBUG, L_SCANNER, "Using last camdate i tem: %s/%s/%s/%X\n", camera, last_camdate.name, last_camdate.parentID, last_camd ate.objectID);
} }
else else
{ {
insert_container(date_taken, last_cam.parentID, NULL, "al bum.photoAlbum", NULL, NULL, NULL, &objectID, &parentID); insert_container(date_taken, last_cam.parentID, NULL, "al bum.photoAlbum", NULL, NULL, NULL, &objectID, &parentID);
sprintf(last_camdate.parentID, "%s$%llX", last_cam.parent ID, (long long)parentID); sprintf(last_camdate.parentID, "%.63s$%llX", last_cam.par entID, (long long)parentID);
last_camdate.objectID = objectID; last_camdate.objectID = objectID;
strncpyt(last_camdate.name, date_taken, sizeof(last_camda te.name)); strncpyt(last_camdate.name, date_taken, sizeof(last_camda te.name));
//DEBUG DPRINTF(E_DEBUG, L_SCANNER, "Creating cached camd ate item: %s/%s/%s/%X\n", camera, last_camdate.name, last_camdate.parentID, last _camdate.objectID); //DEBUG DPRINTF(E_DEBUG, L_SCANNER, "Creating cached camd ate item: %s/%s/%s/%X\n", camera, last_camdate.name, last_camdate.parentID, last _camdate.objectID);
} }
sql_exec(db, "INSERT into OBJECTS" sql_exec(db, "INSERT into OBJECTS"
" (OBJECT_ID, PARENT_ID, REF_ID, CLASS, DETAIL_ID, N AME) " " (OBJECT_ID, PARENT_ID, REF_ID, CLASS, DETAIL_ID, N AME) "
"VALUES" "VALUES"
" ('%s$%llX', '%s', '%s', '%s', %lld, %Q)", " ('%s$%llX', '%s', '%s', '%s', %lld, %Q)",
last_camdate.parentID, last_camdate.objectID, last_c amdate.parentID, refID, class, (long long)detailID, name); last_camdate.parentID, last_camdate.objectID, last_c amdate.parentID, refID, class, (long long)detailID, name);
/* All Images */ /* All Images */
skipping to change at line 280 skipping to change at line 280
if( artist ) if( artist )
{ {
if( !valid_cache || strcmp(artist, last_artist.name) != 0 ) if( !valid_cache || strcmp(artist, last_artist.name) != 0 )
{ {
insert_container(artist, MUSIC_ARTIST_ID, NULL, " person.musicArtist", NULL, genre, NULL, &objectID, &parentID); insert_container(artist, MUSIC_ARTIST_ID, NULL, " person.musicArtist", NULL, genre, NULL, &objectID, &parentID);
sprintf(last_artist.parentID, MUSIC_ARTIST_ID"$%l lX", (long long)parentID); sprintf(last_artist.parentID, MUSIC_ARTIST_ID"$%l lX", (long long)parentID);
strncpyt(last_artist.name, artist, sizeof(last_ar tist.name)); strncpyt(last_artist.name, artist, sizeof(last_ar tist.name));
last_artistAlbum.name[0] = '\0'; last_artistAlbum.name[0] = '\0';
/* Add this file to the "- All Albums -" containe r as well */ /* Add this file to the "- All Albums -" containe r as well */
insert_container(_("- All Albums -"), last_artist .parentID, NULL, "album", artist, genre, NULL, &objectID, &parentID); insert_container(_("- All Albums -"), last_artist .parentID, NULL, "album", artist, genre, NULL, &objectID, &parentID);
sprintf(last_artistAlbumAll.parentID, "%s$%llX", last_artist.parentID, (long long)parentID); sprintf(last_artistAlbumAll.parentID, "%.63s$%llX ", last_artist.parentID, (long long)parentID);
last_artistAlbumAll.objectID = objectID; last_artistAlbumAll.objectID = objectID;
} }
else else
{ {
last_artistAlbumAll.objectID++; last_artistAlbumAll.objectID++;
} }
if( valid_cache && strcmp(album?album:_("Unknown Album"), last_artistAlbum.name) == 0 ) if( valid_cache && strcmp(album?album:_("Unknown Album"), last_artistAlbum.name) == 0 )
{ {
last_artistAlbum.objectID++; last_artistAlbum.objectID++;
//DEBUG DPRINTF(E_DEBUG, L_SCANNER, "Using last a rtist/album item: %s/%s/%X\n", last_artist.name, last_artist.parentID, last_arti st.objectID); //DEBUG DPRINTF(E_DEBUG, L_SCANNER, "Using last a rtist/album item: %s/%s/%X\n", last_artist.name, last_artist.parentID, last_arti st.objectID);
} }
else else
{ {
insert_container(album?album:_("Unknown Album"), last_artist.parentID, album?last_album.parentID:NULL, insert_container(album?album:_("Unknown Album"), last_artist.parentID, album?last_album.parentID:NULL,
"album.musicAlbum", artist, genr e, album_art, &objectID, &parentID); "album.musicAlbum", artist, genr e, album_art, &objectID, &parentID);
sprintf(last_artistAlbum.parentID, "%s$%llX", las t_artist.parentID, (long long)parentID); sprintf(last_artistAlbum.parentID, "%.63s$%llX", last_artist.parentID, (long long)parentID);
last_artistAlbum.objectID = objectID; last_artistAlbum.objectID = objectID;
strncpyt(last_artistAlbum.name, album ? album : _ ("Unknown Album"), sizeof(last_artistAlbum.name)); strncpyt(last_artistAlbum.name, album ? album : _ ("Unknown Album"), sizeof(last_artistAlbum.name));
//DEBUG DPRINTF(E_DEBUG, L_SCANNER, "Creating cac hed artist/album item: %s/%s/%X\n", last_artist.name, last_artist.parentID, last _artist.objectID); //DEBUG DPRINTF(E_DEBUG, L_SCANNER, "Creating cac hed artist/album item: %s/%s/%X\n", last_artist.name, last_artist.parentID, last _artist.objectID);
} }
sql_exec(db, "INSERT into OBJECTS" sql_exec(db, "INSERT into OBJECTS"
" (OBJECT_ID, PARENT_ID, REF_ID, CLASS, DETA IL_ID, NAME) " " (OBJECT_ID, PARENT_ID, REF_ID, CLASS, DETA IL_ID, NAME) "
"VALUES" "VALUES"
" ('%s$%llX', '%s', '%s', '%s', %lld, %Q)", " ('%s$%llX', '%s', '%s', '%s', %lld, %Q)",
last_artistAlbum.parentID, last_artistAlbum. objectID, last_artistAlbum.parentID, refID, class, (long long)detailID, name); last_artistAlbum.parentID, last_artistAlbum. objectID, last_artistAlbum.parentID, refID, class, (long long)detailID, name);
sql_exec(db, "INSERT into OBJECTS" sql_exec(db, "INSERT into OBJECTS"
skipping to change at line 321 skipping to change at line 321
} }
if( genre ) if( genre )
{ {
if( !valid_cache || strcmp(genre, last_genre.name) != 0 ) if( !valid_cache || strcmp(genre, last_genre.name) != 0 )
{ {
insert_container(genre, MUSIC_GENRE_ID, NULL, "ge nre.musicGenre", NULL, NULL, NULL, &objectID, &parentID); insert_container(genre, MUSIC_GENRE_ID, NULL, "ge nre.musicGenre", NULL, NULL, NULL, &objectID, &parentID);
sprintf(last_genre.parentID, MUSIC_GENRE_ID"$%llX ", (long long)parentID); sprintf(last_genre.parentID, MUSIC_GENRE_ID"$%llX ", (long long)parentID);
strncpyt(last_genre.name, genre, sizeof(last_genr e.name)); strncpyt(last_genre.name, genre, sizeof(last_genr e.name));
/* Add this file to the "- All Artists -" contain er as well */ /* Add this file to the "- All Artists -" contain er as well */
insert_container(_("- All Artists -"), last_genre .parentID, NULL, "person", NULL, genre, NULL, &objectID, &parentID); insert_container(_("- All Artists -"), last_genre .parentID, NULL, "person", NULL, genre, NULL, &objectID, &parentID);
sprintf(last_genreArtistAll.parentID, "%s$%llX", last_genre.parentID, (long long)parentID); sprintf(last_genreArtistAll.parentID, "%.63s$%llX ", last_genre.parentID, (long long)parentID);
last_genreArtistAll.objectID = objectID; last_genreArtistAll.objectID = objectID;
} }
else else
{ {
last_genreArtistAll.objectID++; last_genreArtistAll.objectID++;
} }
if( valid_cache && strcmp(artist?artist:_("Unknown Artist "), last_genreArtist.name) == 0 ) if( valid_cache && strcmp(artist?artist:_("Unknown Artist "), last_genreArtist.name) == 0 )
{ {
last_genreArtist.objectID++; last_genreArtist.objectID++;
} }
else else
{ {
insert_container(artist?artist:_("Unknown Artist" ), last_genre.parentID, artist?last_artist.parentID:NULL, insert_container(artist?artist:_("Unknown Artist" ), last_genre.parentID, artist?last_artist.parentID:NULL,
"person.musicArtist", NULL, genr e, NULL, &objectID, &parentID); "person.musicArtist", NULL, genr e, NULL, &objectID, &parentID);
sprintf(last_genreArtist.parentID, "%s$%llX", las t_genre.parentID, (long long)parentID); sprintf(last_genreArtist.parentID, "%.63s$%llX", last_genre.parentID, (long long)parentID);
last_genreArtist.objectID = objectID; last_genreArtist.objectID = objectID;
strncpyt(last_genreArtist.name, artist ? artist : _("Unknown Artist"), sizeof(last_genreArtist.name)); strncpyt(last_genreArtist.name, artist ? artist : _("Unknown Artist"), sizeof(last_genreArtist.name));
//DEBUG DPRINTF(E_DEBUG, L_SCANNER, "Creating cac hed genre/artist item: %s/%s/%X\n", last_genreArtist.name, last_genreArtist.pare ntID, last_genreArtist.objectID); //DEBUG DPRINTF(E_DEBUG, L_SCANNER, "Creating cac hed genre/artist item: %s/%s/%X\n", last_genreArtist.name, last_genreArtist.pare ntID, last_genreArtist.objectID);
} }
sql_exec(db, "INSERT into OBJECTS" sql_exec(db, "INSERT into OBJECTS"
" (OBJECT_ID, PARENT_ID, REF_ID, CLASS, DETA IL_ID, NAME) " " (OBJECT_ID, PARENT_ID, REF_ID, CLASS, DETA IL_ID, NAME) "
"VALUES" "VALUES"
" ('%s$%llX', '%s', '%s', '%s', %lld, %Q)", " ('%s$%llX', '%s', '%s', '%s', %lld, %Q)",
last_genreArtist.parentID, last_genreArtist. objectID, last_genreArtist.parentID, refID, class, (long long)detailID, name); last_genreArtist.parentID, last_genreArtist. objectID, last_genreArtist.parentID, refID, class, (long long)detailID, name);
sql_exec(db, "INSERT into OBJECTS" sql_exec(db, "INSERT into OBJECTS"
skipping to change at line 494 skipping to change at line 494
strcpy(base, MUSIC_DIR_ID); strcpy(base, MUSIC_DIR_ID);
class = "item.audioItem.musicTrack"; class = "item.audioItem.musicTrack";
detailID = GetAudioMetadata(path, name); detailID = GetAudioMetadata(path, name);
} }
if( !detailID ) if( !detailID )
{ {
DPRINTF(E_WARN, L_SCANNER, "Unsuccessful getting details for %s\n ", path); DPRINTF(E_WARN, L_SCANNER, "Unsuccessful getting details for %s\n ", path);
return -1; return -1;
} }
sprintf(objectID, "%s%s$%X", BROWSEDIR_ID, parentID, object); snprintf(objectID, sizeof(objectID), "%s%s$%X", BROWSEDIR_ID, parentID, o bject);
objname = strdup(name); objname = strdup(name);
strip_ext(objname); strip_ext(objname);
sql_exec(db, "INSERT into OBJECTS" sql_exec(db, "INSERT into OBJECTS"
" (OBJECT_ID, PARENT_ID, CLASS, DETAIL_ID, NAME) " " (OBJECT_ID, PARENT_ID, CLASS, DETAIL_ID, NAME) "
"VALUES" "VALUES"
" ('%s', '%s%s', '%s', %lld, '%q')", " ('%s', '%s%s', '%s', %lld, '%q')",
objectID, BROWSEDIR_ID, parentID, class, detailID, objname); objectID, BROWSEDIR_ID, parentID, class, detailID, objname);
if( *parentID ) if( *parentID )
skipping to change at line 904 skipping to change at line 904
void void
start_scanner(void) start_scanner(void)
{ {
struct media_dir_s *media_path; struct media_dir_s *media_path;
char path[MAXPATHLEN]; char path[MAXPATHLEN];
if (setpriority(PRIO_PROCESS, 0, 15) == -1) if (setpriority(PRIO_PROCESS, 0, 15) == -1)
DPRINTF(E_WARN, L_INOTIFY, "Failed to reduce scanner thread prio rity\n"); DPRINTF(E_WARN, L_INOTIFY, "Failed to reduce scanner thread prio rity\n");
setlocale(LC_COLLATE, ""); setlocale(LC_COLLATE, "");
av_register_all(); lav_register_all();
av_log_set_level(AV_LOG_PANIC); av_log_set_level(AV_LOG_PANIC);
if( GETFLAG(RESCAN_MASK) ) if( GETFLAG(RESCAN_MASK) )
return start_rescan(); return start_rescan();
for( media_path = media_dirs; media_path != NULL; media_path = media_path ->next ) for( media_path = media_dirs; media_path != NULL; media_path = media_path ->next )
{ {
int64_t id; int64_t id;
char *bname, *parent = NULL; char *bname, *parent = NULL;
char buf[8]; char buf[8];
strncpyt(path, media_path->path, sizeof(path)); strncpyt(path, media_path->path, sizeof(path));
bname = basename(path); bname = basename(path);
/* If there are multiple media locations, add a level to the Cont entDirectory */ /* If there are multiple media locations, add a level to the Cont entDirectory */
if( !GETFLAG(MERGE_MEDIA_DIRS_MASK) && media_dirs->next ) if( !GETFLAG(MERGE_MEDIA_DIRS_MASK) && media_dirs->next )
{ {
int startID = get_next_available_id("OBJECTS", BROWSEDIR_ ID); int startID = get_next_available_id("OBJECTS", BROWSEDIR_ ID);
id = insert_directory(bname, path, BROWSEDIR_ID, "", star tID); id = insert_directory(bname, path, BROWSEDIR_ID, "", star tID);
sprintf(buf, "$%X", startID); snprintf(buf, sizeof(buf), "$%X", startID);
parent = buf; parent = buf;
} }
else else
id = GetFolderMetadata(bname, media_path->path, NULL, NUL L, 0); id = GetFolderMetadata(bname, media_path->path, NULL, NUL L, 0);
/* Use TIMESTAMP to store the media type */ /* Use TIMESTAMP to store the media type */
sql_exec(db, "UPDATE DETAILS set TIMESTAMP = %d where ID = %lld", media_path->types, (long long)id); sql_exec(db, "UPDATE DETAILS set TIMESTAMP = %d where ID = %lld", media_path->types, (long long)id);
ScanDirectory(media_path->path, parent, media_path->types); ScanDirectory(media_path->path, parent, media_path->types);
sql_exec(db, "INSERT into SETTINGS values (%Q, %Q)", "media_dir", media_path->path); sql_exec(db, "INSERT into SETTINGS values (%Q, %Q)", "media_dir", media_path->path);
} }
/* Create this index after scanning, so it doesn't slow down the scanning process. /* Create this index after scanning, so it doesn't slow down the scanning process.
 End of changes. 9 change blocks. 
9 lines changed or deleted 9 lines changed or added

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