<commit_before>var fs = require('fs'),
    path = require('path');

var queue_file = '/tmp/haraka.eml';

exports.register = function() {
    var config_path = this.config.get('queue/file_output') || queue_file;

    queue_file = path.resolve(config_path);
};

/**
 * append the incoming mail to the queue file.
 * @param  {Function} next       processing callback
 * @param  {Object}   connection connection information
 */
exports.hook_queue = function(next, connection) {
    var ws = fs.createWriteStream(queue_file);

    ws.once('close', function () {
        return next(OK);
    });

    connection.transaction.message_stream.pipe(ws);<commit_msg>append incoming mails to file queue instead of overwriting<commit_after>var fs = require('fs'),
    path = require('path');

var queue_file = '/tmp/haraka.eml',
    stream_opts = {
        flags: 'a',
        encoding: 'utf-8'
    };

exports.register = function() {
    var config_path = this.config.get('queue/file_output') || queue_file;

    queue_file = path.resolve(config_path);
};

/**
 * append the incoming mail to the queue file.
 * @param  {Function} next       processing callback
 * @param  {Object}   connection connection information
 */
exports.hook_queue = function(next, connection) {
    var ws = fs.createWriteStream(queue_file, stream_opts);

    ws.once('close', function () {
        return next(OK);
    });

    connection.transaction.message_stream.pipe(ws);
{'fraction_non_alphanumeric': 0.13551077136900624, 'fraction_numerical': 0.0006949270326615705, 'mean_word_length': 3.5425867507886437, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5654443', 'n_tokens_mistral': 435, 'n_tokens_neox': 424, 'n_words': 103}