Commit a6c46d5e authored by priit's avatar priit
Browse files

Mitme faili haldamise err

parent 0001c14b
......@@ -5,6 +5,7 @@ var fs = require('fs');
var daoService = require('./daoService');
var Session = require('../model/session');
var FileUtil = require('../util/file');
var async = require('async');
function SessionService() {
......@@ -53,27 +54,23 @@ function SessionService() {
tmpList.push(files[i]);
}
if(tmpList.length > 0){
self._storeOnIndex(session, tmpList, 0, cb)
}
};
this._storeOnIndex = function (session, tmpList, index, cb) {
var tmpFile = tmpList[index];
var sessionFilePath = this.getNewFilePath(session.id);
async.eachSeries(
tmpList,
function (item, callback) {
FileUtil.mv(tmpFile.path, sessionFilePath, function(err){
if(err) return cb(err);
session.requestFiles[tmpFile.fieldname] = sessionFilePath;
var tmpFile = item;
var sessionFilePath = self.getNewFilePath(session.id);
if(index < tmpList - 1){
index = index + 1;
self._storeOnIndex(session, tmpList, 0, cb)
} else {
cb(null, session);
FileUtil.mv(tmpFile.path, sessionFilePath, function(err){
if(err) return callback(err);
session.requestFiles[tmpFile.fieldname] = sessionFilePath;
callback();
});
},
function ( err, session ) {
cb( err, session );
}
});
);
};
this.getStorePath = function (sessionId) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment