Browse Source

fix cross-filesystem symlink issues

master
poikilos 6 years ago
committed by Jacob Gustafson
parent
commit
1e51a23a3b
  1. 29
      webapp/server.js

29
webapp/server.js

@ -7,7 +7,8 @@
const profilePath = require('os').homedir(); const profilePath = require('os').homedir();
var skinDir = profilePath + "/minetest/games/ENLIVEN/mods/codercore/coderskins/textures"; var minetestPath = profilePath + "/minetest"; // TODO: differs from .minetest if not RUN_IN_PLACE
var skinDir = "";
var tz_offset = 240; //subtract this from server time to get local time; 4hrs is 240; 5hrs is 300 var tz_offset = 240; //subtract this from server time to get local time; 4hrs is 240; 5hrs is 300
// TODO: handle tz_offset not divisible by 60 // TODO: handle tz_offset not divisible by 60
// var selected_date_s = null; // var selected_date_s = null;
@ -54,6 +55,10 @@ var unique_flags = [
]; ];
//#endregion derived from mtsenliven.py //#endregion derived from mtsenliven.py
function regeneratePaths() {
skinDir = minetestPath + "/games/ENLIVEN/mods/codercore/coderskins/textures";
}
function process_logline(line, line_number) { function process_logline(line, line_number) {
//selected_date_s //selected_date_s
//TODO: use store_unique_log_data instead of this function //TODO: use store_unique_log_data instead of this function
@ -342,17 +347,24 @@ app.post('/set-skin', function (req, res){
destNameNoExt = destNameNoExt = "player_" + fields.userName; destNameNoExt = destNameNoExt = "player_" + fields.userName;
directPath = skinDir + "/" + destNameNoExt + ".png"; directPath = skinDir + "/" + destNameNoExt + ".png";
indirectPath = skinDir + "/" + destNameNoExt + ".skin"; indirectPath = skinDir + "/" + destNameNoExt + ".skin";
// TODO: make sure my_file and project_id values are present // TODO: make sure my_file and userName values are present
if (files.userFile != undefined) { if (files.userFile != undefined) {
if (userName != undefined) {
var originalPath = files.userFile.path; var originalPath = files.userFile.path;
console.log("trying to rename " + files.userFile.path console.log("trying to rename " + files.userFile.path
+ " to " + directPath); + " to " + directPath);
fs.rename(files.userFile.path, directPath, function(err) { fs.rename(files.userFile.path, directPath, function(err) {
if (err) { if (err) {
msg = "Failed to rename " + originalPath msg = "Failed to rename " + originalPath
+ " to " + directPath + "<br/>\n"; + " to " + directPath;
console.log(msg); console.log(msg);
next(err); msg += "<br/>\n";
//next(err);
// TODO: why does next above show:
//ReferenceError: next is not defined
//at /home/owner/git/EnlivenMinetest/webapp/server.js:355:6
//at FSReqWrap.oncomplete (fs.js:135:15)
} }
else { else {
var thisData = destNameNoExt + ".png"; var thisData = destNameNoExt + ".png";
@ -365,6 +377,10 @@ app.post('/set-skin', function (req, res){
res.end(); res.end();
}); });
} }
else {
console.log("userName is undefined.");
}
}
else { else {
console.log("userFile is undefined."); console.log("userFile is undefined.");
} }
@ -450,6 +466,11 @@ Your browser does not support the canvas element.
var server = app.listen(3000, function () { var server = app.listen(3000, function () {
//console.log('express-handlebars example server listening on: 3000'); //console.log('express-handlebars example server listening on: 3000');
var thisMinetest = "/tank/local/owner/minetest";
if (fs.existsSync(thisMinetest)) {
minetestPath = thisMinetest;
}
regeneratePaths();
var host = server.address().address; var host = server.address().address;
var port = server.address().port; var port = server.address().port;
console.log("server address:"); console.log("server address:");

Loading…
Cancel
Save