Fix various inotify issues with deleting entire folder contents, and then re-adding content back to the same folder. This should be the cause of '(null)' folder names.

This commit is contained in:
Justin Maggard 2013-09-18 15:29:59 -07:00
parent 701b2efacd
commit bb163eb65f

View File

@ -540,8 +540,7 @@ inotify_remove_file(const char * path)
if( ends_with(path, ".srt") ) if( ends_with(path, ".srt") )
{ {
rows = sql_exec(db, "DELETE from CAPTIONS where PATH = '%q'", path); return sql_exec(db, "DELETE from CAPTIONS where PATH = '%q'", path);
return rows;
} }
/* Invalidate the scanner cache so we don't insert files into non-existent containers */ /* Invalidate the scanner cache so we don't insert files into non-existent containers */
valid_cache = 0; valid_cache = 0;
@ -563,11 +562,13 @@ inotify_remove_file(const char * path)
else else
{ {
/* Delete the parent containers if we are about to empty them. */ /* Delete the parent containers if we are about to empty them. */
snprintf(sql, sizeof(sql), "SELECT PARENT_ID from OBJECTS where DETAIL_ID = %lld", (long long int)detailID); snprintf(sql, sizeof(sql), "SELECT PARENT_ID from OBJECTS where DETAIL_ID = %lld"
" and PARENT_ID not like '64$%%'",
(long long int)detailID);
if( (sql_get_table(db, sql, &result, &rows, NULL) == SQLITE_OK) ) if( (sql_get_table(db, sql, &result, &rows, NULL) == SQLITE_OK) )
{ {
int i, children; int i, children;
for( i=1; i <= rows; i++ ) for( i = 1; i <= rows; i++ )
{ {
/* If it's a playlist item, adjust the item count of the playlist */ /* If it's a playlist item, adjust the item count of the playlist */
if( strncmp(result[i], MUSIC_PLIST_ID, strlen(MUSIC_PLIST_ID)) == 0 ) if( strncmp(result[i], MUSIC_PLIST_ID, strlen(MUSIC_PLIST_ID)) == 0 )
@ -581,8 +582,6 @@ inotify_remove_file(const char * path)
continue; continue;
if( children < 2 ) if( children < 2 )
{ {
sql_exec(db, "DELETE from DETAILS where ID ="
" (SELECT DETAIL_ID from OBJECTS where OBJECT_ID = '%s')", result[i]);
sql_exec(db, "DELETE from OBJECTS where OBJECT_ID = '%s'", result[i]); sql_exec(db, "DELETE from OBJECTS where OBJECT_ID = '%s'", result[i]);
ptr = strrchr(result[i], '$'); ptr = strrchr(result[i], '$');
@ -590,8 +589,6 @@ inotify_remove_file(const char * path)
*ptr = '\0'; *ptr = '\0';
if( sql_get_int_field(db, "SELECT count(*) from OBJECTS where PARENT_ID = '%s'", result[i]) == 0 ) if( sql_get_int_field(db, "SELECT count(*) from OBJECTS where PARENT_ID = '%s'", result[i]) == 0 )
{ {
sql_exec(db, "DELETE from DETAILS where ID ="
" (SELECT DETAIL_ID from OBJECTS where OBJECT_ID = '%s')", result[i]);
sql_exec(db, "DELETE from OBJECTS where OBJECT_ID = '%s'", result[i]); sql_exec(db, "DELETE from OBJECTS where OBJECT_ID = '%s'", result[i]);
} }
} }