Permalink
Browse files

Resolved bug introduced with commit b1f9f1d

On branch master
Changes to be committed:
modified:   examples/simple/simpleUpload.js
modified:   lib/formaline.js
modified:   package.json
  • Loading branch information...
1 parent 9afbd94 commit 91143f7d2a4772165fb6b7ff748865f07e8dcc5c @rootslab rootslab committed Nov 6, 2012
Showing with 29 additions and 23 deletions.
  1. +2 −2 examples/simple/simpleUpload.js
  2. +26 −20 lib/formaline.js
  3. +1 −1 package.json
@@ -141,7 +141,7 @@ var http = require( 'http' ),
// console: 'off' --> disable console log output
// record: 'on' --> record binary data from client request
// See the Readme!
- logging : 'debug:on,1:on,2:off,3:off,4:off,console:on,file:off,record:off', // <-- turn off 2nd level to see only warnings, and parser overall results
+ logging : 'debug:on,1:on,2:off,3:off,4:off,console:on,file:off,record:on', // <-- turn off 2nd level to see only warnings, and parser overall results
// listeners
listeners : {
@@ -226,7 +226,7 @@ var http = require( 'http' ),
server = connect( getHtmlForm , handleFormRequest );
-server.listen( 3000 );
+server.listen( 3001 );
log();
log( ' ->\033[1m started at: \033[32m' + new Date() + '\033[0m' );
View
@@ -693,19 +693,6 @@ fproto.parseMultipartData = function ( chunk, cback ) {
var writeToFileStream = function ( dataPayload, cfg ) {
try {
- var jsonFileProgression = function(file, me) {
- return {
- name : file.fieldname,
- value : {
- name : file.origname,
- path : file.path,
- type : file.ctype,
- size : me.fileSize,
- lastModifiedDate : file.mtime,
- sha1checksum : null
- }
- };
- };
if ( dataPayload ) {
me.fileStream.write( dataPayload );
me.fileStream.mtime = new Date(); // it is quite accurate when file data were received in only one chunk
@@ -714,21 +701,40 @@ fproto.parseMultipartData = function ( chunk, cback ) {
me.fileSize += dataPayload.length;
me.bytesWrittenToDisk += dataPayload.length;
if ( me.emitFileProgress ) {
- var jsonFileProg = jsonFileProgression(file, me)
- var file = me.fileStream, jsonFileProg;
- me.emitEvent( 'fileprogress', jsonFileProg, 4, dataPayload );
+ var file = me.fileStream,
+ jsonFileProgression = {
+ name : file.fieldname,
+ value : {
+ name : file.origname,
+ path : file.path,
+ type : file.ctype,
+ size : me.fileSize,
+ lastModifiedDate : file.mtime,
+ sha1checksum : null
+ }
+ };
+ me.emitEvent( 'fileprogress', jsonFileProgression, 4, dataPayload );
}
} else {
if ( cfg && cfg.path ) {
- me.fileStream = new fs.WriteStream( cfg.path );
+ var file = me.fileStream = new fs.WriteStream( cfg.path );
me.fileSize = 0;
// https://github.com/rootslab/formaline/issues/37
-
// the first fileprogress event would still need to fire as per usual, but the filestart
// event would need to fire just before without a buffer and with the
// info.value.size set to 0.
- var jsonFileProg = jsonFileProgression(file, me);
- me.emitEvent( 'filestart', jsonFileProg);
+ me.emitEvent( 'filestart', {
+ name : file.fieldname,
+ value : {
+ name : file.origname,
+ path : file.path,
+ type : file.ctype,
+ size : me.fileSize,
+ lastModifiedDate : file.mtime,
+ sha1checksum : null
+ }
+ } );
+
apply( me.fileStream, cfg, true );
if ( ! isWindows ) {
View
@@ -1,6 +1,6 @@
{
"name" : "formaline"
- , "version" : "0.6.6"
+ , "version" : "0.6.7"
, "description" : "formaline, a module for handling form requests ( HTTP POST / PUT ) and for fast parsing of file uploads, it is also ready to use with middlewares like connect"
, "homepage" : "https://github.com/rootslab/formaline"
, "repository" : {

0 comments on commit 91143f7

Please sign in to comment.