--- minidlna-1.3.3/monitor.c.orig +++ minidlna-1.3.3/monitor.c @@ -298,6 +298,7 @@ char path_buf[PATH_MAX]; enum file_types type = TYPE_UNKNOWN; media_types dir_types; + struct stat st; if( access(path, R_OK|X_OK) != 0 ) { @@ -341,22 +342,21 @@ continue; esc_name = escape_tag(e->d_name, 1); snprintf(path_buf, sizeof(path_buf), "%s/%s", path, e->d_name); - switch( e->d_type ) + if ((stat(path_buf, &st) == 0) && + (S_ISDIR(st.st_mode)||S_ISREG(st.st_mode)||S_ISLNK(st.st_mode))) { - case DT_DIR: - case DT_REG: - case DT_LNK: - case DT_UNKNOWN: - type = resolve_unknown_type(path_buf, dir_types); - default: - break; - } - if( type == TYPE_DIR ) - { - monitor_insert_directory(fd, esc_name, path_buf); - } - else if( type == TYPE_FILE && check_notsparse(path_buf)) { - monitor_insert_file(esc_name, path_buf); + type = resolve_unknown_type(path_buf, dir_types); + if( type == TYPE_DIR ) + { + monitor_insert_directory(fd, esc_name, path_buf); + } + else if( type == TYPE_FILE ) + { + if(st.st_blocks<<9 >= st.st_size) + { + monitor_insert_file(esc_name, path_buf); + } + } } free(esc_name); }