Skip to content

Commit

Permalink
Merge pull request #150 from 1000TurquoisePogs/bugfix/node6zos
Browse files Browse the repository at this point in the history
Tweak how binary is written to work around behavior of node6 on zos
  • Loading branch information
DNikolaevAtRocket authored Sep 27, 2019
2 parents 5a88c43 + 339264a commit ec02b66
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions plugins/config/lib/configService.js
Original file line number Diff line number Diff line change
Expand Up @@ -1571,21 +1571,20 @@ function replaceOrCreateFile(response, filename, directories, scope, relativePat
var mode = 0700; //TODO is 700 good for us?
//mode is for if the file is created.
//w means create if doesnt exist, and open for writing

fs.open(path,'w',mode,function(error, fd) {
if (!error) {
var offset = 0;
var contentLength = content.length;
var buff;
if (binary) {
buff = new Uint8Array(Buffer.from(content));
buff = Buffer.from(content);
} else {
buff = Buffer.from(content,'utf8');
}
var writeCallback = function(err,writtenLength,buffer) {
contentLength -= writtenLength;
offset += writtenLength;
if (contentLength == 0) {
if (contentLength <= 0) {
var handleException = function(e) {
respondWithJsonError(response,"Failed to close written item.",HTTP_STATUS_INTERNAL_SERVER_ERROR,location);
logger.warn('Error occurred while closing file. File='+path+'. Error='+e.message);
Expand Down Expand Up @@ -1639,7 +1638,7 @@ function replaceOrCreateFile(response, filename, directories, scope, relativePat
fs.write(fd,buff,offset,contentLength,writeCallback);
}
};
fs.write(fd,buff,offset,contentLength,writeCallback);
fs.write(fd,buff,writeCallback);
}
else {
logger.warn('Exception when opening file for writing. File='+path+'. Error='+error.message);
Expand Down

0 comments on commit ec02b66

Please sign in to comment.