mirror of
https://github.com/owntone/owntone-server.git
synced 2025-02-03 09:56:00 -05:00
Fix date_added, modified problems. Also, fix db_exists
This commit is contained in:
parent
2861761d36
commit
9559452124
@ -768,7 +768,7 @@ int db_add(MP3FILE *pmp3) {
|
||||
ppacked=(MP3PACKED *)pnew->dptr;
|
||||
if(!ppacked->time_added)
|
||||
ppacked->time_added=(int)time(NULL);
|
||||
ppacked->time_modified=ppacked->time_added;
|
||||
ppacked->time_modified=(int)time(NULL);
|
||||
ppacked->time_played=0; /* do we want to keep track of this? */
|
||||
|
||||
if(gdbm_store(db_songs,dkey,*pnew,GDBM_REPLACE)) {
|
||||
@ -1192,10 +1192,18 @@ int db_exists(int id) {
|
||||
int *node;
|
||||
int err;
|
||||
MP3FILE *pmp3;
|
||||
datum key,content;
|
||||
|
||||
/* this is wrong and expensive */
|
||||
DPRINTF(ERR_DEBUG,"Checking if node %d in db\n");
|
||||
key.dptr=(char*)&id;
|
||||
key.dsize=sizeof(int);
|
||||
|
||||
pmp3=db_find(id);
|
||||
content=gdbm_fetch(db_songs,key);
|
||||
MEMNOTIFY(content.dptr);
|
||||
if(!content.dptr) {
|
||||
DPRINTF(ERR_DEBUG,"Nope! Not in DB\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(db_update_mode) {
|
||||
/* knock it off the maybe list */
|
||||
@ -1205,8 +1213,10 @@ int db_exists(int id) {
|
||||
free(node);
|
||||
}
|
||||
}
|
||||
|
||||
return pmp3 ? 1 : 0;
|
||||
|
||||
free(content.dptr);
|
||||
DPRINTF(ERR_DEBUG,"Yup, in database\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -376,6 +376,8 @@ int scan_path(char *path) {
|
||||
|
||||
/* only scan if it's been changed, or empty db */
|
||||
modified_time=sb.st_mtime;
|
||||
DPRINTF(ERR_DEBUG,"FS Modified time: %d\n",modified_time);
|
||||
DPRINTF(ERR_DEBUG,"DB Modified time: %d\n",db_last_modified(sb.st_ino));
|
||||
if((scan_mode_foreground) ||
|
||||
!db_exists(sb.st_ino) ||
|
||||
db_last_modified(sb.st_ino) < modified_time) {
|
||||
@ -490,6 +492,7 @@ void scan_music_file(char *path, struct dirent *pde, struct stat *psb) {
|
||||
mp3file.time_added=psb->st_mtime;
|
||||
if(psb->st_ctime < mp3file.time_added)
|
||||
mp3file.time_added=psb->st_ctime;
|
||||
mp3file.time_modified=time(NULL);
|
||||
|
||||
DPRINTF(ERR_DEBUG," Date Added: %d\n",mp3file.time_added);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user