mirror of
https://github.com/owntone/owntone-server.git
synced 2025-02-24 03:49:14 -05:00
Fix miscounted items on rescans
This commit is contained in:
parent
1b38b66340
commit
be980f515d
@ -1018,6 +1018,7 @@ int db_add(MP3FILE *pmp3) {
|
|||||||
datum dkey;
|
datum dkey;
|
||||||
MP3PACKED *ppacked;
|
MP3PACKED *ppacked;
|
||||||
unsigned long int id;
|
unsigned long int id;
|
||||||
|
int new=1;
|
||||||
|
|
||||||
DPRINTF(E_DBG,L_DB,"Adding %s\n",pmp3->path);
|
DPRINTF(E_DBG,L_DB,"Adding %s\n",pmp3->path);
|
||||||
|
|
||||||
@ -1030,6 +1031,13 @@ int db_add(MP3FILE *pmp3) {
|
|||||||
dkey.dptr=(void*)&(pmp3->id);
|
dkey.dptr=(void*)&(pmp3->id);
|
||||||
dkey.dsize=sizeof(unsigned long int);
|
dkey.dsize=sizeof(unsigned long int);
|
||||||
|
|
||||||
|
db_gdbmlock();
|
||||||
|
if(gdbm_exists(db_songs,dkey)) {
|
||||||
|
new=0;
|
||||||
|
DPRINTF(E_DBG,L_DB,"this is an update, not an add\n");
|
||||||
|
}
|
||||||
|
db_gdbmunlock();
|
||||||
|
|
||||||
/* dummy this up in case the client didn't */
|
/* dummy this up in case the client didn't */
|
||||||
ppacked=(MP3PACKED *)pnew->dptr;
|
ppacked=(MP3PACKED *)pnew->dptr;
|
||||||
if(!ppacked->time_added)
|
if(!ppacked->time_added)
|
||||||
@ -1048,26 +1056,15 @@ int db_add(MP3FILE *pmp3) {
|
|||||||
}
|
}
|
||||||
db_gdbmunlock();
|
db_gdbmunlock();
|
||||||
|
|
||||||
DPRINTF(E_DBG,L_DB,"Testing for %lu\n",pmp3->id);
|
|
||||||
id=pmp3->id;
|
|
||||||
dkey.dptr=(void*)&id;
|
|
||||||
dkey.dsize=sizeof(unsigned long int);
|
|
||||||
|
|
||||||
db_gdbmlock();
|
|
||||||
if(!gdbm_exists(db_songs,dkey)) {
|
|
||||||
db_gdbmunlock();
|
|
||||||
DPRINTF(E_FATAL,L_DB,"Error.. could not find just added file\n");
|
|
||||||
}
|
|
||||||
db_gdbmunlock();
|
|
||||||
|
|
||||||
free(pnew->dptr);
|
free(pnew->dptr);
|
||||||
free(pnew);
|
free(pnew);
|
||||||
|
|
||||||
db_version_no++;
|
db_version_no++;
|
||||||
|
|
||||||
|
if(new)
|
||||||
db_song_count++;
|
db_song_count++;
|
||||||
|
|
||||||
DPRINTF(E_DBG,L_DB,"Added file\n");
|
DPRINTF(E_DBG,L_DB,"%s file\n", new ? "Added" : "Updated");
|
||||||
|
|
||||||
db_unlock();
|
db_unlock();
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user