diff --git a/gui/preload-chat.js b/gui/preload-chat.js index 59d35ed6..37c4d002 100644 --- a/gui/preload-chat.js +++ b/gui/preload-chat.js @@ -4,7 +4,7 @@ const { v4: uuidv4 } = require("uuid"); const imageCompression = require("browser-image-compression"); const blobUtil = require("blob-util"); const FD = require("./freedata"); -const fs = require('fs'); +const fs = require("fs"); // https://stackoverflow.com/a/26227660 var appDataFolder = @@ -831,7 +831,10 @@ ipcRenderer.on("action-new-msg-received", (event, arg) => { if (config.enable_request_shared_folder == "True") { sendSharedFolderList(item.dxcallsign); } - } else if (splitted_data[1] == "req" && splitted_data[2].substring(0,1) == "2") { + } else if ( + splitted_data[1] == "req" && + splitted_data[2].substring(0, 1) == "2" + ) { let name = splitted_data[2].substring(1); //console.log("In handle req for shared folder file"); obj.uuid = uuidv4().toString(); @@ -847,7 +850,7 @@ ipcRenderer.on("action-new-msg-received", (event, arg) => { obj.file = "null"; if (config.enable_request_shared_folder == "True") { - sendSharedFolderFile(item.dxcallsign,name); + sendSharedFolderFile(item.dxcallsign, name); } } else if (splitted_data[1] == "res-0") { obj.uuid = uuidv4().toString(); @@ -903,7 +906,7 @@ ipcRenderer.on("action-new-msg-received", (event, arg) => { getSetUserInformation(selected_callsign); } else if (splitted_data[1] == "res-2") { console.log("In received respons-2"); - let sharedFileInfo = splitted_data[2].split("/",2); + let sharedFileInfo = splitted_data[2].split("/", 2); obj.uuid = uuidv4().toString(); obj.timestamp = Math.floor(Date.now() / 1000); @@ -2127,19 +2130,18 @@ function sendSharedFolderList(dxcallsign) { }); } -function sendSharedFolderFile(dxcallsign,filename) { - - let filePath = path.join(config.shared_folder_path,filename); +function sendSharedFolderFile(dxcallsign, filename) { + let filePath = path.join(config.shared_folder_path, filename); console.log("In fuction sendSharedFolderFile ", filePath); - - //Make sure nothing sneaky is going on + + //Make sure nothing sneaky is going on if (!filePath.startsWith(config.shared_folder_path)) { console.error("File is outside of shared folder path!"); return; } - + if (!fs.existsSync(filePath)) { - console.warn("File doesn't seem to exist"); + console.warn("File doesn't seem to exist"); return; } @@ -2147,19 +2149,19 @@ function sendSharedFolderFile(dxcallsign,filename) { let fileData = null; try { //Has to be binary - let data = fs.readFileSync(filePath) - fileData = data.toString("utf-8"); + let data = fs.readFileSync(filePath); + fileData = data.toString("utf-8"); } catch (err) { console.log(err); return; } - - ipcRenderer.send("run-tnc-command", { - command: "responseSharedFile", - dxcallsign: dxcallsign, - file: filename, - filedata: fileData - }); + + ipcRenderer.send("run-tnc-command", { + command: "responseSharedFile", + dxcallsign: dxcallsign, + file: filename, + filedata: fileData, + }); } function sendUserData(dxcallsign) { diff --git a/gui/sock.js b/gui/sock.js index 882c139a..11ff5ead 100644 --- a/gui/sock.js +++ b/gui/sock.js @@ -745,8 +745,17 @@ exports.sendResponseSharedFolderList = function (dxcallsign, sharedFolderList) { }; //Send shared file response -exports.sendResponseSharedFile = function (dxcallsign, sharedFile, sharedFileData) { - console.log("In sendResponseSharedFile",dxcallsign,sharedFile,sharedFileData) +exports.sendResponseSharedFile = function ( + dxcallsign, + sharedFile, + sharedFileData +) { + console.log( + "In sendResponseSharedFile", + dxcallsign, + sharedFile, + sharedFileData + ); //Command 0 = user/station information //Command 1 = shared folder list //Command 2 = shared file transfer