]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
com_add: Minor improvements.
authorAndre Noll <maan@systemlinux.org>
Thu, 13 Sep 2007 17:09:24 +0000 (19:09 +0200)
committerAndre Noll <maan@systemlinux.org>
Thu, 13 Sep 2007 17:09:24 +0000 (19:09 +0200)
Continue if an audio file could not be added and print proper error
message in case of errors.

aft.c
error.h

diff --git a/aft.c b/aft.c
index 9ec977613e0b78f36d5ef56e974ed986cef85ca8..82724c3d10ca578bde9e662803571c5fee333e49 100644 (file)
--- a/aft.c
+++ b/aft.c
@@ -1456,11 +1456,8 @@ static int add_one_audio_file(const char *arg, const void *private_data)
         */
        if (!hs || (pad->flags & ADD_FLAG_FORCE)) {
                ret = compute_afhi(path, map.data, map.size, &afhi);
-               if (ret < 0) {
-                       ret = send_va_buffer(pad->fd,
-                               "audio format of %s not recognized\n", path);
+               if (ret < 0)
                        goto out_unmap;
-               }
                format_num = ret;
                afhi_ptr = &afhi;
        }
@@ -1473,6 +1470,9 @@ static int add_one_audio_file(const char *arg, const void *private_data)
 out_unmap:
        munmap(map.data, map.size);
 out_free:
+       if (ret < 0)
+               send_va_buffer(pad->fd, "failed to add %s (%s)\n", path,
+                       PARA_STRERROR(-ret));
        free(obj.data);
        free(path);
        if (afhi_ptr)
@@ -1517,16 +1517,11 @@ int com_add(int fd, int argc, char * const * const argv)
                if (S_ISDIR(statbuf.st_mode)) {
                        ret = for_each_file_in_dir(argv[i],
                                add_one_audio_file, &pad);
-                       if (ret < 0)
-                               return ret;
                        continue;
                }
                ret = add_one_audio_file(argv[i], &pad);
-               if (ret < 0)
-                       goto out;
        }
        ret = 1;
-out:
        return ret;
 
 }
diff --git a/error.h b/error.h
index 9bc8ed525316f81027dcb9dbb9fa8f8206ed3e3e..1be0536ed67cec6ab80423d51e4e1e9b4ef8c319 100644 (file)
--- a/error.h
+++ b/error.h
@@ -131,15 +131,15 @@ extern const char **para_errlist[];
        PARA_ERROR(INDEX_CORRUPTION, "fixme"), \
        PARA_ERROR(BAD_OFFSET, "fixme"), \
        PARA_ERROR(INVALID_OBJECT, "fixme"), \
-       PARA_ERROR(MKDIR, "fixme"), \
-       PARA_ERROR(OPEN, "fixme"), \
-       PARA_ERROR(STAT, "fixme"), \
-       PARA_ERROR(FSTAT, "fixme"), \
+       PARA_ERROR(MKDIR, "failed to create directory"), \
+       PARA_ERROR(OPEN, "failed to open file"), \
+       PARA_ERROR(STAT, "can not stat file"), \
+       PARA_ERROR(FSTAT, "fstat error"), \
        PARA_ERROR(RENAME, "fixme"), \
-       PARA_ERROR(EMPTY, "fixme"), \
+       PARA_ERROR(EMPTY, "file empty"), \
        PARA_ERROR(NOSPC, "fixme"), \
-       PARA_ERROR(MMAP, "fixme"), \
-       PARA_ERROR(MUNMAP, "fixme"), \
+       PARA_ERROR(MMAP, "mmap error"), \
+       PARA_ERROR(MUNMAP, "munmap failed"), \
        PARA_ERROR(WRITE, "fixme"), \
        PARA_ERROR(LSEEK, "fixme"), \
        PARA_ERROR(BUSY, "fixme"), \