<commit_before>var EventProxy = require('eventproxy');

var config = require('../config');
var ERR = require('../errorcode');

var mFile = require('../models/file');

exports.delete = function(req, res){
    var params = req.body;

    var fileIds = params.fileId;
    var groupId = params.groupId;

    var creator = req.loginUser._id;

    var ep = new EventProxy();

    ep.fail(function(err){
        res.json({ err: ERR.SERVER_ERROR, msg: err});
    });

    ep.after('delete', fileIds.length, function(list){
        res.json({
            err: ERR.SUCCESS
        });
    });

    fileIds.forEach(function(fileId){
        mFile.delete({ 
            fileId: fileId, 
            groupId: groupId
        }, ep.group('delete'));
    });

}

exports.revert = function(req, res){

    var params = req.body;

    var fileIds = params.fileId;
    var groupId = params.groupId;

    var creator = req.loginUser._id;

    var ep = new EventProxy();

    ep.fail(function(err){
        res.json({ err: ERR.SERVER_ERROR, msg: err});
    });

    ep.after('revert', fileIds.length, function(list){
        res.json({
            err: ERR.SUCCESS
        });
    });

    fileIds.forEach(function(fileId){
        mFile.revertDelete({ 
            fileId: fileId, 
            groupId: groupId
        }, ep.group('revert'));
    });
}


exports.search = function(req, res){
    var params = req.query;

    params.extendQuery = {
        del: true,
    }
    if(!params.groupId){ // TODO 小组的回收站要怎么处理
        params.creator = req.loginUser._id; // 只能搜索自己的回收站
    }
    mFile.search(params, function(err, total, docs){
        if(err){
            res.json({ err: ERR.SERVER_ERROR, msg: err});
        }else{
            res.json({
                err: ERR.SUCCESS,
                result: {
                    total: total,
                    list: docs
                }
            });
        }
    });
}
<commit_msg>bugfix<commit_after>var EventProxy = require('eventproxy');

var config = require('../config');
var ERR = require('../errorcode');

var mFile = require('../models/file');

exports.delete = function(req, res){
    var params = req.body;

    var fileIds = params.fileId;
    var groupId = params.groupId;

    var creator = req.loginUser._id;

    var ep = new EventProxy();

    ep.fail(function(err){
        res.json({ err: ERR.SERVER_ERROR, msg: err});
    });

    ep.after('delete', fileIds.length, function(list){
        res.json({
            err: ERR.SUCCESS
        });
    });

    fileIds.forEach(function(fileId){
        mFile.delete({ 
            fileId: fileId, 
            groupId: groupId,
            creator: creator
        }, ep.group('delete'));
    });

}

exports.revert = function(req, res){

    var params = req.body;

    var fileIds = params.fileId;
    var groupId = params.groupId;

    var creator = req.loginUser._id;

    var ep = new EventProxy();

    ep.fail(function(err){
        res.json({ err: ERR.SERVER_ERROR, msg: err});
    });

    ep.after('revert', fileIds.length, function(list){
        res.json({
            err: ERR.SUCCESS
        });
    });

    fileIds.forEach(function(fileId){
        mFile.revertDelete({ 
            fileId: fileId, 
            groupId: groupId
        }, ep.group('revert'));
    });
}


exports.search = function(req, res){
    var params = req.query;

    params.extendQuery = {
        del: true,
    }
    if(!params.groupId){ // TODO 小组的回收站要怎么处理
        params.creator = req.loginUser._id; // 只能搜索自己的回收站
    }
    mFile.search(params, function(err, total, docs){
        if(err){
            res.json({ err: ERR.SERVER_ERROR, msg: err});
        }else{
            res.json({
                err: ERR.SUCCESS,
                result: {
                    total: total,
                    list: docs
                }
            });
        }
    });
}

{'fraction_non_alphanumeric': 0.14651825006471655, 'fraction_numerical': 0.0, 'mean_word_length': 1.8101818181818181, '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': '3067268', 'n_tokens_mistral': 1250, 'n_tokens_neox': 1208, 'n_words': 246}