]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
robustness fixes for the random selector
authorAndre <maan@meins.(none)>
Mon, 11 Sep 2006 22:57:10 +0000 (00:57 +0200)
committerAndre <maan@meins.(none)>
Mon, 11 Sep 2006 22:57:10 +0000 (00:57 +0200)
- do not abort if stat for an audio file failed. Simply skip this file
  instead.

- return proper error message if custom function failed.

- do not error out if the second scan for audio files yields more
  files than the previous run. This happens if audio files are
  added during the audio file scan of the random selector.

db.c
error.h
random_selector.c

diff --git a/db.c b/db.c
index 9db622bca3ca6447fcc1659a0c270d49d2b36f60..8b06672606e50009004bd9dcf89625425295035b 100644 (file)
--- a/db.c
+++ b/db.c
@@ -75,14 +75,15 @@ int find_audio_files(const char *dirname, int (*f)(const char *, const char *))
                        continue;
                ret = -E_LSTAT;
                if (lstat(entry->d_name, &s) == -1)
                        continue;
                ret = -E_LSTAT;
                if (lstat(entry->d_name, &s) == -1)
-                       goto out;
+                       continue;
                m = s.st_mode;
                if (!S_ISREG(m) && !S_ISDIR(m)) /* skip links, sockets, ... */
                        continue;
                if (S_ISREG(m)) { /* regular file */
                        if (guess_audio_format(entry->d_name) < 0)
                                continue;
                m = s.st_mode;
                if (!S_ISREG(m) && !S_ISDIR(m)) /* skip links, sockets, ... */
                        continue;
                if (S_ISREG(m)) { /* regular file */
                        if (guess_audio_format(entry->d_name) < 0)
                                continue;
-                       if (f(dirname, entry->d_name) < 0)
+                       ret = f(dirname, entry->d_name);
+                       if (ret < 0)
                                goto out;
                        continue;
                }
                                goto out;
                        continue;
                }
diff --git a/error.h b/error.h
index 0f83398e7aae6333446ee45555a0fd91879e152f..cb5e2b023bfda5d8759bc594a0b559fabf0b42a7 100644 (file)
--- a/error.h
+++ b/error.h
@@ -321,7 +321,6 @@ extern const char **para_errlist[];
 
 
 #define RANDOM_SELECTOR_ERRORS \
 
 
 #define RANDOM_SELECTOR_ERRORS \
-       PARA_ERROR(FILE_COUNT, "audio file count exceeded"), \
        PARA_ERROR(NOTHING_FOUND, "no audio files found"), \
 
 
        PARA_ERROR(NOTHING_FOUND, "no audio files found"), \
 
 
index 123425b0b8d3df18a5b624481babd5e2ae61b666..7bf34026941f8fcfa0553e26c69b3e66a7a5830e 100644 (file)
@@ -40,10 +40,11 @@ static int count_audio_files(__a_unused const char *dir, __a_unused const char *
 
 static int remember_file(const char *dir, const char *name)
 {
 
 static int remember_file(const char *dir, const char *name)
 {
-       if (audio_file_count >= num_audio_files)
-               return -E_FILE_COUNT;
-       audio_file_list[audio_file_count] = make_message("%s/%s", dir, name);
-       audio_file_count++;
+       if (audio_file_count < num_audio_files) {
+               audio_file_list[audio_file_count] =
+                       make_message("%s/%s", dir, name);
+               audio_file_count++;
+       }
        return 1;
 }
 
        return 1;
 }