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;
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;
}
}
*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;
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. */
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;
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) {
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;
}
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);
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) {