* Fix inotify detection issue on first-level folders.
This commit is contained in:
parent
edcdb027d0
commit
0919e28b3a
@ -592,6 +592,8 @@ inotify_remove_directory(int fd, const char * path)
|
|||||||
sqlite_int64 detailID = 0;
|
sqlite_int64 detailID = 0;
|
||||||
int rows, i, ret = 1;
|
int rows, i, ret = 1;
|
||||||
|
|
||||||
|
/* Invalidate the scanner cache so we don't insert files into non-existent containers */
|
||||||
|
valid_cache = 0;
|
||||||
remove_watch(fd, path);
|
remove_watch(fd, path);
|
||||||
sql = sqlite3_mprintf("SELECT ID from DETAILS where PATH glob '%q/*'"
|
sql = sqlite3_mprintf("SELECT ID from DETAILS where PATH glob '%q/*'"
|
||||||
" UNION ALL SELECT ID from DETAILS where PATH = '%q'", path, path);
|
" UNION ALL SELECT ID from DETAILS where PATH = '%q'", path, path);
|
||||||
|
33
scanner.c
33
scanner.c
@ -132,7 +132,7 @@ insert_container(const char * item, const char * rootParent, const char * refID,
|
|||||||
static void
|
static void
|
||||||
insert_containers(const char * name, const char *path, const char * refID, const char * class, sqlite_int64 detailID)
|
insert_containers(const char * name, const char *path, const char * refID, const char * class, sqlite_int64 detailID)
|
||||||
{
|
{
|
||||||
char *sql;
|
char sql[128];
|
||||||
char **result;
|
char **result;
|
||||||
int ret;
|
int ret;
|
||||||
int cols, row;
|
int cols, row;
|
||||||
@ -147,9 +147,8 @@ insert_containers(const char * name, const char *path, const char * refID, const
|
|||||||
static struct virtual_item last_camdate;
|
static struct virtual_item last_camdate;
|
||||||
static sqlite_int64 last_all_objectID = 0;
|
static sqlite_int64 last_all_objectID = 0;
|
||||||
|
|
||||||
asprintf(&sql, "SELECT DATE, CREATOR from DETAILS where ID = %lld", detailID);
|
snprintf(sql, sizeof(sql), "SELECT DATE, CREATOR from DETAILS where ID = %lld", detailID);
|
||||||
ret = sql_get_table(db, sql, &result, &row, &cols);
|
ret = sql_get_table(db, sql, &result, &row, &cols);
|
||||||
free(sql);
|
|
||||||
if( ret == SQLITE_OK )
|
if( ret == SQLITE_OK )
|
||||||
{
|
{
|
||||||
date = result[2];
|
date = result[2];
|
||||||
@ -231,9 +230,8 @@ insert_containers(const char * name, const char *path, const char * refID, const
|
|||||||
}
|
}
|
||||||
else if( strstr(class, "audioItem") )
|
else if( strstr(class, "audioItem") )
|
||||||
{
|
{
|
||||||
asprintf(&sql, "SELECT ALBUM, ARTIST, GENRE, ALBUM_ART from DETAILS where ID = %lld", detailID);
|
snprintf(sql, sizeof(sql), "SELECT ALBUM, ARTIST, GENRE, ALBUM_ART from DETAILS where ID = %lld", detailID);
|
||||||
ret = sql_get_table(db, sql, &result, &row, &cols);
|
ret = sql_get_table(db, sql, &result, &row, &cols);
|
||||||
free(sql);
|
|
||||||
if( ret != SQLITE_OK )
|
if( ret != SQLITE_OK )
|
||||||
return;
|
return;
|
||||||
if( !row )
|
if( !row )
|
||||||
@ -398,24 +396,26 @@ insert_directory(const char * name, const char * path, const char * base, const
|
|||||||
sqlite_int64 detailID = 0;
|
sqlite_int64 detailID = 0;
|
||||||
char * refID = NULL;
|
char * refID = NULL;
|
||||||
char class[] = "container.storageFolder";
|
char class[] = "container.storageFolder";
|
||||||
char * id_buf = NULL;
|
|
||||||
char * parent_buf = NULL;
|
|
||||||
char *dir_buf, *dir;
|
|
||||||
char *result, *p;
|
char *result, *p;
|
||||||
static char last_found[256] = "-1";
|
static char last_found[256] = "-1";
|
||||||
|
|
||||||
if( strcmp(base, BROWSEDIR_ID) != 0 )
|
if( strcmp(base, BROWSEDIR_ID) != 0 )
|
||||||
asprintf(&refID, "%s%s$%X", BROWSEDIR_ID, parentID, objectID);
|
{
|
||||||
|
if( asprintf(&refID, "%s%s$%X", BROWSEDIR_ID, parentID, objectID) == -1 )
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if( refID )
|
if( refID )
|
||||||
{
|
{
|
||||||
|
char id_buf[64], parent_buf[64];
|
||||||
|
char *dir_buf, *dir;
|
||||||
dir_buf = strdup(path);
|
dir_buf = strdup(path);
|
||||||
dir = dirname(dir_buf);
|
dir = dirname(dir_buf);
|
||||||
asprintf(&id_buf, "%s%s$%X", base, parentID, objectID);
|
snprintf(id_buf, sizeof(id_buf), "%s%s$%X", base, parentID, objectID);
|
||||||
asprintf(&parent_buf, "%s%s", base, parentID);
|
snprintf(parent_buf, sizeof(parent_buf), "%s%s", base, parentID);
|
||||||
while( !found )
|
while( !found )
|
||||||
{
|
{
|
||||||
if( strcmp(id_buf, last_found) == 0 )
|
if( valid_cache && strcmp(id_buf, last_found) == 0 )
|
||||||
break;
|
break;
|
||||||
if( sql_get_int_field(db, "SELECT count(*) from OBJECTS where OBJECT_ID = '%s'", id_buf) > 0 )
|
if( sql_get_int_field(db, "SELECT count(*) from OBJECTS where OBJECT_ID = '%s'", id_buf) > 0 )
|
||||||
{
|
{
|
||||||
@ -443,10 +443,8 @@ insert_directory(const char * name, const char * path, const char * base, const
|
|||||||
dir = dirname(dir);
|
dir = dirname(dir);
|
||||||
}
|
}
|
||||||
free(refID);
|
free(refID);
|
||||||
free(parent_buf);
|
|
||||||
free(id_buf);
|
|
||||||
free(dir_buf);
|
free(dir_buf);
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
detailID = GetFolderMetadata(name, path, NULL, NULL, find_album_art(path, NULL, 0));
|
detailID = GetFolderMetadata(name, path, NULL, NULL, find_album_art(path, NULL, 0));
|
||||||
@ -457,7 +455,7 @@ insert_directory(const char * name, const char * path, const char * base, const
|
|||||||
base, parentID, objectID, base, parentID, refID, detailID, class, name);
|
base, parentID, objectID, base, parentID, refID, detailID, class, name);
|
||||||
free(refID);
|
free(refID);
|
||||||
|
|
||||||
return -1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -809,6 +807,7 @@ void
|
|||||||
start_scanner()
|
start_scanner()
|
||||||
{
|
{
|
||||||
struct media_dir_s * media_path = media_dirs;
|
struct media_dir_s * media_path = media_dirs;
|
||||||
|
char name[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 priority\n");
|
DPRINTF(E_WARN, L_INOTIFY, "Failed to reduce scanner thread priority\n");
|
||||||
@ -821,6 +820,8 @@ start_scanner()
|
|||||||
freopen("/dev/null", "a", stderr);
|
freopen("/dev/null", "a", stderr);
|
||||||
while( media_path )
|
while( media_path )
|
||||||
{
|
{
|
||||||
|
strncpy(name, media_path->path, sizeof(name));
|
||||||
|
GetFolderMetadata(basename(name), media_path->path, NULL, NULL, 0);
|
||||||
ScanDirectory(media_path->path, NULL, media_path->type);
|
ScanDirectory(media_path->path, NULL, media_path->type);
|
||||||
media_path = media_path->next;
|
media_path = media_path->next;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user