morris / vinyl-ftp

Blazing fast vinyl adapter for FTP
Other
388 stars 31 forks source link

Best way to handle errors on file uploads #58

Closed scramble45 closed 8 years ago

scramble45 commented 8 years ago

Im wondering what the best way to handle errors when uploading a file is. Below is my example of how I'm thinking this may work.

fs.src( [ file_path ], { buffer: false } )

.pipe( conn.newerOrDifferentSize( directory_to_create ) )
    .pipe(conn.dest( directory_to_create, function(err) { console.log(err);  if(err){// Do something Here} else {}} ));

}

So I guess my real question is should I expect a FTP or an FS error error when uploading a file. My goal is to just make sure all uploads go through without issue and if an error occurs I will be pushing them to a async.queue which will try to re-upload the file.

morris commented 8 years ago

The vinyl-ftp API is mostly streams, so you'd attach .on( 'error', function ( err ) { ... } ) to them. Only exceptions are rmdir and delete which are callback-based.