Mercurial > dovecot > original-hg > dovecot-1.2
changeset 1186:6dc4f89b53c4 HEAD
Do tmp -> new using link() + unlink(). Use "new" way for unique filename
generation.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 17 Feb 2003 22:45:02 +0200 |
parents | 66bf2aaf74dc |
children | e042bed705af |
files | src/lib-storage/index/maildir/maildir-save.c |
diffstat | 1 files changed, 15 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/maildir/maildir-save.c Mon Feb 17 21:09:43 2003 +0200 +++ b/src/lib-storage/index/maildir/maildir-save.c Mon Feb 17 22:45:02 2003 +0200 @@ -33,7 +33,7 @@ hostpid_init(); - return t_strdup_printf("%s.%s_%u.%s", dec2str(ioloop_time), + return t_strdup_printf("%s.P%sQ%u.%s", dec2str(ioloop_time), my_pid, create_count++, my_hostname); } @@ -97,29 +97,30 @@ const char *src, const char *dest) { const char *tmp_path, *new_path; + int failed; t_push(); tmp_path = t_strconcat(ctx->tmpdir, "/", src, NULL); new_path = t_strconcat(ctx->newdir, "/", dest, NULL); - if (rename(tmp_path, new_path) == 0) { - t_pop(); - return TRUE; - } - - if (errno == ENOSPC) { - mail_storage_set_error(ctx->ibox->box.storage, - "Not enough disk space"); - } else { - mail_storage_set_critical(ctx->ibox->box.storage, - "rename(%s, %s) failed: %m", - tmp_path, new_path); + if (link(tmp_path, new_path) == 0) + failed = FALSE; + else { + failed = TRUE; + if (errno == ENOSPC) { + mail_storage_set_error(ctx->ibox->box.storage, + "Not enough disk space"); + } else { + mail_storage_set_critical(ctx->ibox->box.storage, + "link(%s, %s) failed: %m", + tmp_path, new_path); + } } (void)unlink(tmp_path); t_pop(); - return FALSE; + return !failed; } int maildir_storage_save_next(struct mail_save_context *ctx,