Mercurial > dovecot > core-2.2
changeset 11826:7520b31ea95b
dbox: Split dbox_file_seek() from dbox_file_get_mail_stream()
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 15 Jul 2010 16:59:11 +0100 |
parents | b6693d570960 |
children | cd1dbde147cd |
files | src/lib-storage/index/dbox-common/dbox-file.c src/lib-storage/index/dbox-common/dbox-file.h src/lib-storage/index/dbox-common/dbox-mail.c src/lib-storage/index/dbox-multi/mdbox-purge.c src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c |
diffstat | 6 files changed, 24 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/dbox-common/dbox-file.c Thu Jul 15 16:39:51 2010 +0100 +++ b/src/lib-storage/index/dbox-common/dbox-file.c Thu Jul 15 16:59:11 2010 +0100 @@ -367,8 +367,7 @@ return 1; } -int dbox_file_get_mail_stream(struct dbox_file *file, uoff_t offset, - struct istream **stream_r) +int dbox_file_seek(struct dbox_file *file, uoff_t offset) { uoff_t size; int ret; @@ -387,10 +386,18 @@ file->cur_physical_size = size; } i_stream_seek(file->input, offset + file->msg_header_size); - if (stream_r != NULL) { - *stream_r = i_stream_create_limit(file->input, - file->cur_physical_size); - } + return 1; +} + +int dbox_file_get_mail_stream(struct dbox_file *file, uoff_t offset, + struct istream **stream_r) +{ + int ret; + + if ((ret = dbox_file_seek(file, offset)) <= 0) + return ret; + + *stream_r = i_stream_create_limit(file->input, file->cur_physical_size); return 1; } @@ -447,7 +454,7 @@ } *last_r = FALSE; - ret = dbox_file_get_mail_stream(file, offset, NULL); + ret = dbox_file_seek(file, offset); if (*offset_r == 0) *offset_r = file->file_header_size; return ret;
--- a/src/lib-storage/index/dbox-common/dbox-file.h Thu Jul 15 16:39:51 2010 +0100 +++ b/src/lib-storage/index/dbox-common/dbox-file.h Thu Jul 15 16:59:11 2010 +0100 @@ -153,8 +153,10 @@ int dbox_file_try_lock(struct dbox_file *file); void dbox_file_unlock(struct dbox_file *file); -/* Seek to given offset in file and return the message's input stream. - Returns 1 if ok/expunged, 0 if file/offset is corrupted, -1 if I/O error. */ +/* Seek to given offset in file. Returns 1 if ok/expunged, 0 if file/offset is + corrupted, -1 if I/O error. */ +int dbox_file_seek(struct dbox_file *file, uoff_t offset); +/* Same as dbox_file_seek(), but return also input stream for message. */ int dbox_file_get_mail_stream(struct dbox_file *file, uoff_t offset, struct istream **input_r); /* Start seeking at the beginning of the file. */
--- a/src/lib-storage/index/dbox-common/dbox-mail.c Thu Jul 15 16:39:51 2010 +0100 +++ b/src/lib-storage/index/dbox-common/dbox-mail.c Thu Jul 15 16:59:11 2010 +0100 @@ -45,7 +45,7 @@ if (storage->v.mail_open(mail, &offset, file_r) < 0) return -1; - if (dbox_file_get_mail_stream(*file_r, offset, NULL) <= 0) + if (dbox_file_seek(*file_r, offset) <= 0) return -1; if (dbox_file_metadata_read(*file_r) <= 0) return -1;
--- a/src/lib-storage/index/dbox-multi/mdbox-purge.c Thu Jul 15 16:39:51 2010 +0100 +++ b/src/lib-storage/index/dbox-multi/mdbox-purge.c Thu Jul 15 16:59:11 2010 +0100 @@ -229,7 +229,7 @@ i_array_init(&expunged_map_uids, I_MIN(count, 1)); offset = file->file_header_size; for (i = 0; i < count; i++) { - if ((ret = dbox_file_get_mail_stream(file, offset, NULL)) <= 0) + if ((ret = dbox_file_seek(file, offset)) <= 0) break; if (msgs[i].offset != offset) {
--- a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Thu Jul 15 16:39:51 2010 +0100 +++ b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Thu Jul 15 16:59:11 2010 +0100 @@ -175,8 +175,7 @@ fixed = TRUE; if (!first) { /* seek to the offset where we last left off */ - ret = dbox_file_get_mail_stream(file, - prev_offset, NULL); + ret = dbox_file_seek(file, prev_offset); if (ret <= 0) break; } @@ -613,7 +612,7 @@ file = mdbox_file_init(ctx->storage, msg->file_id); ret = dbox_file_open(file, &deleted); if (ret > 0 && !deleted) - ret = dbox_file_get_mail_stream(file, msg->offset, NULL); + ret = dbox_file_seek(file, msg->offset); if (ret > 0 && !deleted && dbox_file_metadata_read(file) > 0) { mailbox = dbox_file_metadata_get(file, DBOX_METADATA_ORIG_MAILBOX);
--- a/src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c Thu Jul 15 16:39:51 2010 +0100 +++ b/src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c Thu Jul 15 16:59:11 2010 +0100 @@ -34,11 +34,11 @@ if ((ret = dbox_file_open(file, &deleted)) > 0) { if (deleted) return 0; - ret = dbox_file_get_mail_stream(file, 0, NULL); + ret = dbox_file_seek(file, 0); } if (ret == 0) { if ((ret = dbox_file_fix(file, 0)) == 0) - ret = dbox_file_get_mail_stream(file, 0, NULL); + ret = dbox_file_seek(file, 0); } if (ret <= 0) {