[dovecot-cvs] dovecot/src/lib-storage/index/maildir maildir-save.c,1.18,1.19
cras at procontrol.fi
cras at procontrol.fi
Mon Feb 17 22:45:05 EET 2003
Update of /home/cvs/dovecot/src/lib-storage/index/maildir
In directory danu:/tmp/cvs-serv10962
Modified Files:
maildir-save.c
Log Message:
Do tmp -> new using link() + unlink(). Use "new" way for unique filename
generation.
Index: maildir-save.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/maildir/maildir-save.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- maildir-save.c 24 Jan 2003 02:38:37 -0000 1.18
+++ maildir-save.c 17 Feb 2003 20:45:02 -0000 1.19
@@ -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,
More information about the dovecot-cvs
mailing list