Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use fs.stat to check if the path is a file or directory before trying…

… to send it
  • Loading branch information...
commit f6253bdcad7c7a9f54a8d57bc6021bbcb71d3f3f 1 parent fef5aed
@pquerna authored
Showing with 3 additions and 4 deletions.
  1. +3 −4 udp/tftp.js
View
7 udp/tftp.js
@@ -5,7 +5,6 @@
var dgram = require('dgram');
var slog = require('sys').log;
-var path = require('path');
var fs = require('fs');
var SERVER_HOST='127.0.0.1';
@@ -155,12 +154,12 @@ sock = dgram.createSocket("udp4", function (msg, peer) {
var mode = tmp[1];
log(peer, "requested file: "+ filename);
log(peer, "mode: "+ mode);
- path.exists(filename, function (exists) {
- if (exists) {
+ fs.stat(filename, function (err, stats) {
+ if (!err && stats.isFile()) {
startSession(peer, filename);
}
else {
- sendError(peer, ERR_FILE_NOT_FOUND, "no such file: "+ filename);
+ sendError(peer, ERR_FILE_NOT_FOUND, "not a file: "+ filename);
}
});
break;
Please sign in to comment.
Something went wrong with that request. Please try again.