ctx->ctx.finished = TRUE;
- if (mail->box->storage != _ctx->transaction->box->storage)
+ if (mail->box->storage != _ctx->transaction->box->storage ||
+ _ctx->transaction->box->disable_reflink_copy_to)
return mail_storage_copy(_ctx, mail);
src_mbox = (struct mdbox_mailbox *)mail->box;
return 1;
}
-static bool
-sdbox_compatible_file_modes(struct mailbox *box1, struct mailbox *box2)
-{
- return box1->file_create_mode == box2->file_create_mode &&
- box1->file_create_gid == box2->file_create_gid;
-}
-
int sdbox_copy(struct mail_save_context *_ctx, struct mail *mail)
{
struct dbox_save_context *ctx = (struct dbox_save_context *)_ctx;
i_assert((_t->flags & MAILBOX_TRANSACTION_FLAG_EXTERNAL) != 0);
ctx->finished = TRUE;
- if (sdbox_compatible_file_modes(&mbox->box, mail->box)) {
+ if (mail_storage_copy_can_use_hardlink(mail->box, &mbox->box)) {
T_BEGIN {
ret = sdbox_copy_hardlink(_ctx, mail);
} T_END;
return 1;
}
-static bool
-maildir_compatible_file_modes(struct mailbox *box1, struct mailbox *box2)
-{
- return box1->file_create_mode == box2->file_create_mode &&
- box1->file_create_gid == box2->file_create_gid;
-}
-
int maildir_copy(struct mail_save_context *ctx, struct mail *mail)
{
struct mailbox_transaction_context *_t = ctx->transaction;
i_assert((_t->flags & MAILBOX_TRANSACTION_FLAG_EXTERNAL) != 0);
if (mbox->storage->set->maildir_copy_with_hardlinks &&
- maildir_compatible_file_modes(&mbox->box, mail->box)) {
+ mail_storage_copy_can_use_hardlink(mail->box, &mbox->box)) {
T_BEGIN {
ret = maildir_copy_hardlink(ctx, mail);
} T_END;
}
return mailbox_save_finish(&ctx);
}
+
+bool mail_storage_copy_can_use_hardlink(struct mailbox *src,
+ struct mailbox *dest)
+{
+ return src->file_create_mode == src->file_create_mode &&
+ src->file_create_gid == src->file_create_gid &&
+ !dest->disable_reflink_copy_to;
+}
struct mail;
struct mail_save_context;
+struct mailbox;
int mail_storage_copy(struct mail_save_context *ctx, struct mail *mail);
+/* Returns TRUE if mail can be copied using hard linking from src to dest.
+ (Assuming the storage itself supports this.) */
+bool mail_storage_copy_can_use_hardlink(struct mailbox *src,
+ struct mailbox *dest);
+
#endif
unsigned int inbox_user:1;
/* TRUE if this is an INBOX for this namespace (user or shared) */
unsigned int inbox_any:1;
+ /* When copying to this mailbox, require that mailbox_copy() uses
+ mailbox_save_*() to actually save a new physical copy rather than
+ simply incrementing a reference count (e.g. via hard link) */
+ unsigned int disable_reflink_copy_to:1;
};
struct mail_vfuncs {