Mercurial > dovecot > core-2.2
diff src/lib-storage/index/dbox-single/sdbox-file.c @ 18694:9ad3f11617f1
sdbox: When hardlink-copying a mail in alt storage, keep it within the alt storage.
Also make sure that the alt-flag is set correctly no matter where we copy
the mail.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 15 May 2015 11:15:50 +0300 |
parents | 3009a1a6f6d5 |
children | fefaa6d09a81 |
line wrap: on
line diff
--- a/src/lib-storage/index/dbox-single/sdbox-file.c Thu May 14 23:49:12 2015 +0300 +++ b/src/lib-storage/index/dbox-single/sdbox-file.c Fri May 15 11:15:50 2015 +0300 @@ -44,10 +44,7 @@ sdbox_file_init_paths(file, fname); file->uid = uid; } else { - file->file.primary_path = - i_strdup_printf("%s/%s", - mailbox_get_path(&mbox->box), - dbox_generate_tmp_filename()); + sdbox_file_init_paths(file, dbox_generate_tmp_filename()); } } T_END; dbox_file_init(&file->file); @@ -151,16 +148,19 @@ int sdbox_file_assign_uid(struct sdbox_file *file, uint32_t uid) { - const char *old_path, *new_fname, *new_path; + const char *p, *old_path, *dir, *new_fname, *new_path; struct stat st; i_assert(file->uid == 0); i_assert(uid != 0); old_path = file->file.cur_path; + p = strrchr(old_path, '/'); + i_assert(p != NULL); + dir = t_strdup_until(old_path, p); + new_fname = t_strdup_printf(SDBOX_MAIL_FILE_FORMAT, uid); - new_path = t_strdup_printf("%s/%s", mailbox_get_path(&file->mbox->box), - new_fname); + new_path = t_strdup_printf("%s/%s", dir, new_fname); if (stat(new_path, &st) == 0) { mail_storage_set_critical(&file->file.storage->storage,