if (ret < 0)
goto out_free;
ret = guess_audio_format(path);
- if (ret < 0 && !(pad->flags & ADD_FLAG_ALL))
+ if (ret < 0 && !(pad->flags & ADD_FLAG_ALL)) {
+ if (pad->flags & ADD_FLAG_VERBOSE)
+ ret = send_va_buffer(pad->fd, "%s: %s\n",
+ PARA_STRERROR(-ret), path);
+ ret = 1;
goto out_free;
+ }
query.data = path;
query.size = strlen(path) + 1;
ret = send_callback_request(path_brother_callback, &query, &result);
format_num = ret;
afhi_ptr = &afhi;
}
- if (pad->flags & ADD_FLAG_VERBOSE)
- send_va_buffer(pad->fd, "adding %s\n", path);
+ if (pad->flags & ADD_FLAG_VERBOSE) {
+ ret = send_va_buffer(pad->fd, "adding %s\n", path);
+ if (ret < 0)
+ goto out_unmap;
+ }
munmap(map.data, map.size);
save_audio_file_info(hash, path, afhi_ptr, pad->flags, format_num, &obj);
/* Ask afs to consider this entry for adding. */
out_unmap:
munmap(map.data, map.size);
out_free:
- if (ret < 0)
+ if (ret < 0 && ret != -E_SEND)
send_va_buffer(pad->fd, "failed to add %s (%s)\n", path?
path : arg, PARA_STRERROR(-ret));
free(obj.data);
free(path);
if (afhi_ptr)
free(afhi_ptr->chunk_table);
- return 1; /* it's not an error if not all files could be added */
+ /* it's not an error if not all files could be added */
+ return ret == -E_SEND? ret : 1;
}
int com_add(int fd, int argc, char * const * const argv)
if (ret < 0)
PARA_NOTICE_LOG("failed to stat %s (%s)", path,
strerror(errno));
- else
+ else {
if (S_ISDIR(statbuf.st_mode))
- for_each_file_in_dir(path, add_one_audio_file,
+ ret = for_each_file_in_dir(path, add_one_audio_file,
&pad);
else
- add_one_audio_file(path, &pad);
+ ret = add_one_audio_file(path, &pad);
+ if (ret < 0) {
+ send_va_buffer(fd, "%s: %s\n", path, PARA_STRERROR(-ret));
+ free(path);
+ return ret;
+ }
+ }
free(path);
}
ret = 1;