]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-fs: If backend doesn't implement exists(), emulate it with stat().
authorTimo Sirainen <tss@iki.fi>
Fri, 13 Sep 2013 21:26:45 +0000 (00:26 +0300)
committerTimo Sirainen <tss@iki.fi>
Fri, 13 Sep 2013 21:26:45 +0000 (00:26 +0300)
src/lib-fs/fs-api.c

index 5fb99584dda17fb145e4957b6ae63a0a9c6b06ed..899d1ed1723a07882dbf7b55e03384c8c4c20e74 100644 (file)
@@ -536,8 +536,16 @@ void fs_unlock(struct fs_lock **_lock)
 
 int fs_exists(struct fs_file *file)
 {
+       struct stat st;
        int ret;
 
+       if (file->fs->v.exists == NULL) {
+               /* fallback to stat() */
+               if (fs_stat(file, &st) == 0)
+                       return 1;
+               else
+                       return errno == ENOENT ? 0 : -1;
+       }
        T_BEGIN {
                ret = file->fs->v.exists(file);
        } T_END;