Skip to content

Commit

Permalink
Better OS detection for ptarmiganlabs#522
Browse files Browse the repository at this point in the history
  • Loading branch information
mountaindude committed Aug 7, 2022
1 parent 2bc7a61 commit dd17bb9
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions src/routes/disk_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,10 @@ async function handlerFileCopy(request, reply) {

// Check if Butler is running on Linux-ish host and UNC path(s) are specified
// Warn if so, then return error
if (os.platform().toLowerCase() !== 'windows') {
if (globals.hostInfo.si.os.platform.toLowerCase() !== 'windows') {
if (isUncPath(request.body.fromFile) === true) {
globals.logger.warn(
`FILE COPY FROM: UNC paths not supported work on non-Windows OSs ("${
request.body.fromFile
}"). OS is "${os.platform()}".`
`FILE COPY FROM: UNC paths not supported work on non-Windows OSs ("${request.body.fromFile}"). OS is "${globals.hostInfo.si.os.platform}".`
);
reply.send(
httpErrors(
Expand All @@ -53,7 +51,7 @@ async function handlerFileCopy(request, reply) {
}
if (isUncPath(request.body.toFile) === true) {
globals.logger.warn(
`FILE COPY TO: UNC paths not supported on non-Windows OSs ("${request.body.toFile}"). OS is "${os.platform()}".`
`FILE COPY TO: UNC paths not supported on non-Windows OSs ("${request.body.toFile}"). OS is "${globals.hostInfo.si.os.platform}".`
);
reply.send(
httpErrors(
Expand Down Expand Up @@ -148,12 +146,10 @@ async function handlerFileMove(request, reply) {
}
// Check if Butler is running on Linux-ish host and UNC path(s) are specified
// Warn if so, then return error
if (os.platform().toLowerCase() !== 'windows') {
if (globals.hostInfo.si.os.platform.toLowerCase() !== 'windows') {
if (isUncPath(request.body.fromFile) === true) {
globals.logger.warn(
`FILE MOVE FROM: UNC paths not supported work on non-Windows OSs ("${
request.body.fromFile
}"). OS is "${os.platform()}".`
`FILE MOVE FROM: UNC paths not supported work on non-Windows OSs ("${request.body.fromFile}"). OS is "${globals.hostInfo.si.os.platform}".`
);
reply.send(
httpErrors(
Expand All @@ -164,7 +160,7 @@ async function handlerFileMove(request, reply) {
}
if (isUncPath(request.body.toFile) === true) {
globals.logger.warn(
`FILE MOVE TO: UNC paths not supported on non-Windows OSs ("${request.body.toFile}"). OS is "${os.platform()}".`
`FILE MOVE TO: UNC paths not supported on non-Windows OSs ("${request.body.toFile}"). OS is "${globals.hostInfo.si.os.platform}".`
);
reply.send(
httpErrors(
Expand Down Expand Up @@ -233,12 +229,10 @@ async function handlerFileDelete(request, reply) {
} else {
// Check if Butler is running on Linux-ish host and UNC path(s) are specified
// Warn if so, then return error
if (os.platform().toLowerCase() !== 'windows') {
if (globals.hostInfo.si.os.platform.toLowerCase() !== 'windows') {
if (isUncPath(request.body.deleteFile) === true) {
globals.logger.warn(
`FILE COPY FROM: UNC paths not supported work on non-Windows OSs ("${
request.body.deleteFile
}"). OS is "${os.platform()}".`
`FILE DELETE: UNC paths not supported work on non-Windows OSs ("${request.body.deleteFile}"). OS is "${globals.hostInfo.si.os.platform}".`
);
reply.send(
httpErrors(
Expand Down

0 comments on commit dd17bb9

Please sign in to comment.