RLGWebD: replace deprecated fs.exists() with fs.access().
This commit is contained in:
parent
c824ea924c
commit
2f40fc5387
1 changed files with 8 additions and 5 deletions
13
rlgwebd
13
rlgwebd
|
|
@ -486,8 +486,11 @@ function checksaved(user, game, callback, args) {
|
|||
var savedirc = game.uname + "save";
|
||||
var basename = String(pwent.uid) + "-" + user + game.suffix;
|
||||
var savefile = path.join("/var/games/roguelike", savedirc, basename);
|
||||
fs.exists(savefile, function (exist) {
|
||||
args.unshift(exist);
|
||||
fs.access(savefile, function (err) {
|
||||
if (err)
|
||||
args.unshift(false);
|
||||
else
|
||||
args.unshift(true);
|
||||
callback.apply(null, args);
|
||||
});
|
||||
}
|
||||
|
|
@ -838,9 +841,9 @@ function serveStatic(req, res, fname) {
|
|||
path.join(nname, "index.html"); /* it was a directory */
|
||||
var realname = path.join(rlgwebd_options.static_root, nname);
|
||||
var extension = path.extname(realname);
|
||||
fs.exists(realname, function (exists) {
|
||||
fs.access(realname, function (access_err) {
|
||||
var resheaders = {};
|
||||
if (!exists || !extension || extension == ".html")
|
||||
if (access_err || !extension || extension == ".html")
|
||||
resheaders["Content-Type"] = "text/html; charset=utf-8";
|
||||
else if (extension == ".png")
|
||||
resheaders["Content-Type"] = "image/png";
|
||||
|
|
@ -852,7 +855,7 @@ function serveStatic(req, res, fname) {
|
|||
resheaders["Content-Type"] = "image/svg+xml";
|
||||
else
|
||||
resheaders["Content-Type"] = "application/octet-stream";
|
||||
if (exists) {
|
||||
if (!access_err) {
|
||||
fs.readFile(realname, function (error, data) {
|
||||
if (error) {
|
||||
res.writeHead(500, {});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue