Mercurial > dovecot > core-2.2
diff src/lib-storage/index/dbox-single/sdbox-file.c @ 21198:bb081fa224e0
sdbox: Don't log an error if stub is added twice
There's no locking for them, so it's fine if two processes add the same
mail. The second one could be ignored, but it was a bit easier to just
let it rename over the first one.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Wed, 23 Nov 2016 13:25:54 +0200 |
parents | 0fd0fb05e2b3 |
children | 2e2563132d5f |
line wrap: on
line diff
--- a/src/lib-storage/index/dbox-single/sdbox-file.c Wed Nov 23 13:16:19 2016 +0200 +++ b/src/lib-storage/index/dbox-single/sdbox-file.c Wed Nov 23 13:25:54 2016 +0200 @@ -147,7 +147,8 @@ return ret; } -int sdbox_file_assign_uid(struct sdbox_file *file, uint32_t uid) +int sdbox_file_assign_uid(struct sdbox_file *file, uint32_t uid, + bool ignore_if_exists) { const char *p, *old_path, *dir, *new_fname, *new_path; struct stat st; @@ -163,7 +164,7 @@ new_fname = t_strdup_printf(SDBOX_MAIL_FILE_FORMAT, uid); new_path = t_strdup_printf("%s/%s", dir, new_fname); - if (stat(new_path, &st) == 0) { + if (!ignore_if_exists && stat(new_path, &st) == 0) { mail_storage_set_critical(&file->file.storage->storage, "sdbox: %s already exists, rebuilding index", new_path); sdbox_set_mailbox_corrupted(&file->mbox->box);