Skip to content

Commit

Permalink
(simatec) Code fix
Browse files Browse the repository at this point in the history
  • Loading branch information
simatec committed Dec 3, 2024
1 parent d3b8336 commit 152c38e
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion lib/list/cifs.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ function mount(options, log, callback) {
log.debug(`cifs-mount command: "${options.sudo ? 'sudo mount' : 'mount'} -t cifs -o ${options.user ? `username=${options.user},password=****` : ''}${options.cifsDomain ? `,domain=${options.cifsDomain}` : ''}${options.clientInodes ? ',noserverino' : ''}${options.cacheLoose ? ',cache=loose' : ''},rw,forceuid,uid=iobroker,forcegid,gid=iobroker,file_mode=0777,dir_mode=0777 ${options.mount}${dir} ${backupDir}"`);
child_process.exec(`${options.sudo ? 'sudo mount' : 'mount'} -t cifs -o ${options.user ? `username=${options.user},password=${options.pass}` : ''}${options.cifsDomain ? `,domain=${options.cifsDomain}` : ''}${options.clientInodes ? ',noserverino' : ''}${options.cacheLoose ? ',cache=loose' : ''},rw,forceuid,uid=iobroker,forcegid,gid=iobroker,file_mode=0777,dir_mode=0777 ${options.mount}${dir} ${backupDir}`, (error, stdout, stderr) => {
if (error) {
let errLog = '' + error;
let errLog = `${error}`;
try {
const formatPass = options.pass.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
errLog = errLog.replace(new RegExp(formatPass, 'g'), "****");
Expand Down
18 changes: 9 additions & 9 deletions lib/list/dropbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async function list(restoreSource, options, types, log, callback) {
db_dropboxAccessJson = options.dropboxAccessJson !== undefined ? options.dropboxAccessJson : options.dropbox && options.dropbox.dropboxAccessJson !== undefined ? options.dropbox.dropboxAccessJson : '';

const dropbox = new Dropbox();
db_accessToken = await dropbox.getToken(db_dropboxAccessJson, log).catch(err => log.warn('Dropbox Token: ' + err));
db_accessToken = await dropbox.getToken(db_dropboxAccessJson, log).catch(err => log.warn(`Dropbox Token: ${err}`));
} else if (db_dropboxTokenType == 'custom') {
db_accessToken = options.accessToken !== undefined ? options.accessToken : options.dropbox && options.dropbox.accessToken !== undefined ? options.dropbox.accessToken : '';
}
Expand All @@ -35,7 +35,7 @@ async function list(restoreSource, options, types, log, callback) {
}

if (!dir || dir[0] !== '/') {
dir = '/' + (dir || '');
dir = `/${dir || ''}`;
}

try {
Expand All @@ -45,7 +45,7 @@ async function list(restoreSource, options, types, log, callback) {
path: dir.replace(/^\/$/, '')
},
}, (err, result) => {
err && err.error_summary && log.error('Dropbox: ' + JSON.stringify(err.error_summary));
err && err.error_summary && log.error(`Dropbox: ${JSON.stringify(err.error_summary)}`);
if (result && result.entries) {

result = result.entries.map(file => {
Expand Down Expand Up @@ -86,7 +86,7 @@ async function getFile(options, fileName, toStoreName, log, callback) {
db_dropboxAccessJson = options.dropboxAccessJson !== undefined ? options.dropboxAccessJson : options.dropbox && options.dropbox.dropboxAccessJson !== undefined ? options.dropbox.dropboxAccessJson : '';

const dropbox = new Dropbox();
db_accessToken = await dropbox.getToken(db_dropboxAccessJson, log).catch(err => log.warn('Dropbox Token: ' + err));
db_accessToken = await dropbox.getToken(db_dropboxAccessJson, log).catch(err => log.warn(`Dropbox Token: ${err}`));
} else if (db_dropboxTokenType == 'custom') {
db_accessToken = options.accessToken !== undefined ? options.accessToken : options.dropbox && options.dropbox.accessToken !== undefined ? options.dropbox.accessToken : '';
}
Expand All @@ -103,15 +103,15 @@ async function getFile(options, fileName, toStoreName, log, callback) {
}

if (!dir || dir[0] !== '/') {
dir = '/' + (dir || '');
dir = `/${dir || ''}`;
}

try {
log.debug('Dropbox: Download of "' + fileName + '" started');
log.debug(`Dropbox: Download of "${fileName}" started`);

const writeStream = fs.createWriteStream(toStoreName);
writeStream.on('error', err => {
err && log.error('Dropbox: ' + err);
err && log.error(`Dropbox: ${err}`);
callback && callback(err);
callback = null;
});
Expand All @@ -122,8 +122,8 @@ async function getFile(options, fileName, toStoreName, log, callback) {
path: path.join(dir.replace(/^\/$/, ''), onlyFileName).replace(/\\/g, '/')
},
}, (err, result, response) => {
err && log.error('Dropbox: ' + err);
!err && log.debug('Dropbox: Download of "' + fileName + '" done');
err && log.error(`Dropbox: ${err}`);
!err && log.debug(`Dropbox: Download of "${fileName}" done`);
callback && callback(err);
callback = null;
})
Expand Down
20 changes: 10 additions & 10 deletions lib/list/ftp.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ function list(restoreSource, options, types, log, callback) {
}

if (!dir || dir[0] !== '/') {
dir = '/' + (dir || '');
dir = `/${dir || ''}`;
}

client.on('ready', () => {
log.debug('FTP: connected.');
client.list(dir, (err, result) => {
if (err) {
log.error('FTP: ' + err);
log.error(`FTP: ${err}`);
}
client.end();
if (result && result.length) {
Expand All @@ -40,7 +40,7 @@ function list(restoreSource, options, types, log, callback) {
return { path: file.name, name: file.name.replace(/\\/g, '/').split('/').pop(), size: file.size }
}).filter(file => (types.indexOf(file.name.split('_')[0]) !== -1 || types.indexOf(file.name.split('.')[0]) !== -1) && file.name.split('.').pop() == 'gz');
} catch (e) {
log.error('FTP: error on ftp list: ' + e + ' please check the ftp config!!');
log.error(`FTP: error on ftp list: ${e} please check the ftp config!!`);
}

const files = {};
Expand All @@ -51,7 +51,7 @@ function list(restoreSource, options, types, log, callback) {
files[type].push(file);
});
} catch (e) {
log.error('FTP: Files error: ' + e + ' please check the ftp config and try again!!');
log.error(`FTP: Files error: ${e} please check the ftp config and try again!!`);
}

callback && callback(null, files, 'ftp');
Expand Down Expand Up @@ -106,19 +106,19 @@ function getFile(options, fileName, toStoreName, log, callback) {
}

if (!dir || dir[0] !== '/') {
dir = '/' + (dir || '');
dir = `/${dir || ''}`;
}
client.on('ready', () => {
log.debug('FTP: connected.');
log.debug('FTP: Get file: ' + dir + '/' + fileName);
client.get(dir + '/' + fileName, (err, stream) => {
log.debug(`FTP: Get file: ${dir}/${fileName}`);
client.get(`${dir}/${fileName}`, (err, stream) => {
if (err) {
try {
client.end();
} catch (e) {
// ignore
}
log.error('FTP: ' + err);
log.error(`FTP: ${err}`);
if (callback) {
callback(err);
callback = null;
Expand All @@ -135,7 +135,7 @@ function getFile(options, fileName, toStoreName, log, callback) {
});
const writeStream = fs.createWriteStream(toStoreName);
writeStream.on('error', err => {
log.error('FTP: ' + err);
log.error(`FTP: ${err}`);
if (callback) {
callback();
callback = null;
Expand All @@ -144,7 +144,7 @@ function getFile(options, fileName, toStoreName, log, callback) {

stream.pipe(writeStream);
} catch (err) {
log.error('FTP: ' + err);
log.error(`FTP: ${err}`);
if (callback) {
callback(err);
callback = null;
Expand Down
10 changes: 5 additions & 5 deletions lib/oneDriveLib.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class onedrive {
reject();
}
} catch (e) {
log.warn('getAuthorizeUrl Onedrive: ' + e);
log.warn(`getAuthorizeUrl Onedrive: ${e}`);
reject();
}
});
Expand All @@ -56,7 +56,7 @@ class onedrive {
reject();
}
} catch (e) {
log.warn('getClientID Onedrive: ' + e);
log.warn(`getClientID Onedrive: ${e}`);
reject();
}
});
Expand All @@ -78,7 +78,7 @@ class onedrive {
reject();
}
} catch (e) {
log.warn('getRefreshToken Onedrive: ' + e);
log.warn(`getRefreshToken Onedrive: ${e}`);
reject();
}
});
Expand All @@ -100,7 +100,7 @@ class onedrive {
reject();
}
} catch (e) {
log.warn('getToken Onedrive: ' + e);
log.warn(`getToken Onedrive: ${e}`);
reject();
}
});
Expand All @@ -122,7 +122,7 @@ class onedrive {
reject();
}
} catch (e) {
log.warn('refresh_token Onedrive: ' + e);
log.warn(`refresh_token Onedrive: ${e}`);
reject();
}
});
Expand Down
4 changes: 2 additions & 2 deletions lib/scripts/01-mount.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function command(options, log, callback) {
log.debug(`cifs-mount command: "${options.sudo ? 'sudo mount' : 'mount'} -t cifs -o ${options.user ? `username=${options.user},password=****` : ''}${options.cifsDomain ? `,domain=${options.cifsDomain}` : ''}${options.clientInodes ? ',noserverino' : ''}${options.cacheLoose ? ',cache=loose' : ''},rw,forceuid,uid=iobroker,forcegid,gid=iobroker,file_mode=0777,dir_mode=0777 ${options.mount}${options.dir} ${options.backupDir}"`);
child_process.exec(`${options.sudo ? 'sudo mount' : 'mount'} -t cifs -o ${options.user ? `username=${options.user},password=${options.pass}` : ''}${options.cifsDomain ? `,domain=${options.cifsDomain}` : ''}${options.clientInodes ? ',noserverino' : ''}${options.cacheLoose ? ',cache=loose' : ''},rw,forceuid,uid=iobroker,forcegid,gid=iobroker,file_mode=0777,dir_mode=0777 ${options.mount}${options.dir} ${options.backupDir}`, (error, stdout, stderr) => {
if (error) {
let errLog = '' + error;
let errLog = `${error}`;
try {
const formatPass = options.pass.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
errLog = errLog.replace(new RegExp(formatPass, 'g'), "****");
Expand All @@ -114,7 +114,7 @@ function command(options, log, callback) {
} else {
log.debug('mount successfully completed');
options.context.done.push('mount');
fs.writeFileSync(options.fileDir + '/.mount', options.mountType);
fs.writeFileSync(`${options.fileDir}/.mount`, options.mountType);
callback && callback(null, stdout);
}
});
Expand Down
2 changes: 1 addition & 1 deletion lib/scripts/75-googledrive.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function cleanFiles(gDrive, options, dir, names, num, log, errors, callback) {
}
})
.catch(err => {
log.error('Google Drive: ' + err);
log.error(`Google Drive: ${err}`);
callback && callback(err);
});
}
Expand Down
2 changes: 1 addition & 1 deletion lib/scripts/94-umount.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function command(options, log, callback) {
if (options.mountType === 'CIFS' || options.mountType === 'NFS' || options.mountType === 'Expert') {
const child_process = require('node:child_process');

if (fs.existsSync(options.fileDir + '/.mount')) {
if (fs.existsSync(`${options.fileDir}/.mount`)) {
child_process.exec(`mount | grep -o "${options.backupDir}"`, (error, stdout, stderr) => {
if (stdout.includes(options.backupDir)) {
log.debug('mount active, umount is started ...');
Expand Down

0 comments on commit 152c38e

Please sign in to comment.