]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-fs: If fs_get_metadata() isn't implemented, return internal metadata anyway
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 31 Oct 2018 15:19:42 +0000 (17:19 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 8 Nov 2018 15:12:09 +0000 (15:12 +0000)
The metadata is sometimes used for transferring internal metadata within the
files. This metadata isn't stored to disk. So even if the fs driver doesn't
support metadata at all, it should still be possible to get/set the internal
metadata. Setting it was already possible, but getting wasn't.

src/lib-fs/fs-api.c

index 93c9f764eff68d9fd3289fc09ba79f2aa88f3d2f..5712eda483ab1645e2558d94052e761c330dec8a 100644 (file)
@@ -471,6 +471,11 @@ int fs_get_metadata(struct fs_file *file,
        int ret;
 
        if (file->fs->v.get_metadata == NULL) {
+               if (array_is_created(&file->metadata)) {
+                       /* Return internal metadata. */
+                       *metadata_r = &file->metadata;
+                       return 0;
+               }
                fs_set_error(file->fs, "Metadata not supported by backend");
                return -1;
        }