dovecot-2.2: lib-fs: Iterating a nonexistent directory should be...

dovecot at dovecot.org dovecot at dovecot.org
Mon Nov 26 23:03:18 EET 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/bd01ca99bee5
changeset: 15397:bd01ca99bee5
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Nov 26 23:01:28 2012 +0200
description:
lib-fs: Iterating a nonexistent directory should be the same as iterating an empty directory.

diffstat:

 src/lib-fs/fs-api.h   |  3 ++-
 src/lib-fs/fs-posix.c |  2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diffs (25 lines):

diff -r 38f3bd4bf6e3 -r bd01ca99bee5 src/lib-fs/fs-api.h
--- a/src/lib-fs/fs-api.h	Mon Nov 26 22:59:37 2012 +0200
+++ b/src/lib-fs/fs-api.h	Mon Nov 26 23:01:28 2012 +0200
@@ -157,7 +157,8 @@
 void fs_unlock(struct fs_lock **lock);
 
 /* Iterate through all files (but not directories) in the given directory.
-   Doesn't recurse to child directories. */
+   Doesn't recurse to child directories. It's not an error to iterate a
+   nonexistent directory. */
 struct fs_iter *fs_iter_init(struct fs *fs, const char *path);
 /* Returns 0 if ok, -1 if iteration failed. */
 int fs_iter_deinit(struct fs_iter **iter);
diff -r 38f3bd4bf6e3 -r bd01ca99bee5 src/lib-fs/fs-posix.c
--- a/src/lib-fs/fs-posix.c	Mon Nov 26 22:59:37 2012 +0200
+++ b/src/lib-fs/fs-posix.c	Mon Nov 26 23:01:28 2012 +0200
@@ -652,7 +652,7 @@
 	iter->iter.fs = fs;
 	iter->path = i_strdup(path);
 	iter->dir = opendir(path);
-	if (iter->dir == NULL) {
+	if (iter->dir == NULL && errno != ENOENT) {
 		iter->err = errno;
 		fs_set_error(fs, "opendir(%s) failed: %m", path);
 	}


More information about the dovecot-cvs mailing list