]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: mail-duplicate - Change mail_duplicate_check() return type from bool...
authorStephan Bosch <stephan.bosch@open-xchange.com>
Tue, 13 Jul 2021 02:03:42 +0000 (04:03 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Thu, 23 Sep 2021 07:03:28 +0000 (07:03 +0000)
src/lib-storage/mail-duplicate.c
src/lib-storage/mail-duplicate.h

index e51ff4cbfe9d5a44290a0a963dc471d86b1d86dd..2d1a56af1ec8dbd71a1efd7bcc41508009469259 100644 (file)
@@ -246,8 +246,9 @@ static void mail_duplicate_file_free(struct mail_duplicate_file **_file)
        pool_unref(&file->pool);
 }
 
-bool mail_duplicate_check(struct mail_duplicate_db *db,
-                         const void *id, size_t id_size, const char *user)
+enum mail_duplicate_check_result
+mail_duplicate_check(struct mail_duplicate_db *db,
+                    const void *id, size_t id_size, const char *user)
 {
        struct mail_duplicate d;
 
@@ -263,7 +264,9 @@ bool mail_duplicate_check(struct mail_duplicate_db *db,
        d.id_size = id_size;
        d.user = user;
 
-       return hash_table_lookup(db->file->hash, &d) != NULL;
+       return (hash_table_lookup(db->file->hash, &d) != NULL ?
+               MAIL_DUPLICATE_CHECK_RESULT_EXISTS :
+               MAIL_DUPLICATE_CHECK_RESULT_NOT_FOUND);
 }
 
 void mail_duplicate_mark(struct mail_duplicate_db *db,
index 4aa868edba0909ef211ee575d383bd6f7d31a977..7e24e06c3d39ad6200eeb7e091f635c76b73d6dc 100644 (file)
@@ -4,10 +4,18 @@
 struct mail_duplicate_db;
 struct mail_storage_settings;
 
+enum mail_duplicate_check_result {
+       /* The ID exists. The ID is not locked. */
+       MAIL_DUPLICATE_CHECK_RESULT_EXISTS,
+       /* The ID doesn't exist yet. The ID gets locked. */
+       MAIL_DUPLICATE_CHECK_RESULT_NOT_FOUND,
+};
+
 #define MAIL_DUPLICATE_DEFAULT_KEEP (3600 * 24)
 
-bool mail_duplicate_check(struct mail_duplicate_db *db,
-                         const void *id, size_t id_size, const char *user);
+enum mail_duplicate_check_result
+mail_duplicate_check(struct mail_duplicate_db *db,
+                    const void *id, size_t id_size, const char *user);
 void mail_duplicate_mark(struct mail_duplicate_db *db,
                         const void *id, size_t id_size,
                         const char *user, time_t timestamp);