* Fix Samba copy errors with inotify enabled.

This commit is contained in:
Justin Maggard 2009-10-23 01:02:40 +00:00
parent e18cf08880
commit 590f0761f4

View File

@ -399,10 +399,11 @@ inotify_insert_directory(int fd, char *name, const char * path)
char **result;
char *id=NULL, *path_buf, *parent_buf, *esc_name;
int wd;
int rows, i = 0;
int rows;
enum file_types type = TYPE_UNKNOWN;
enum media_types dir_type = ALL_MEDIA;
struct media_dir_s * media_path;
struct stat st;
parent_buf = dirname(strdup(path));
sql = sqlite3_mprintf("SELECT OBJECT_ID from OBJECTS o left join DETAILS d on (d.ID = o.DETAIL_ID)"
@ -438,8 +439,11 @@ inotify_insert_directory(int fd, char *name, const char * path)
}
ds = opendir(path);
if( ds != NULL )
if( !ds )
{
DPRINTF(E_ERROR, L_INOTIFY, "opendir failed! [%s]\n", strerror(errno));
return -1;
}
while( (e = readdir(ds)) )
{
if( strcmp(e->d_name, ".") == 0 ||
@ -464,21 +468,18 @@ inotify_insert_directory(int fd, char *name, const char * path)
inotify_insert_directory(fd, esc_name, path_buf);
}
else if( type == TYPE_FILE )
{
if( (stat(path_buf, &st) == 0) && (st.st_blocks<<9 >= st.st_size) )
{
inotify_insert_file(esc_name, path_buf);
}
}
free(esc_name);
free(path_buf);
}
}
else
{
DPRINTF(E_ERROR, L_INOTIFY, "opendir failed! [%s]\n", strerror(errno));
}
closedir(ds);
i++;
return(i);
return 0;
}
int