More robust handling of mount timeout environment variable

This commit is contained in:
Di Weng 2024-10-07 23:47:16 +08:00 committed by GitHub
parent 78a75e8775
commit a366460ae3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 1 deletions

View File

@ -10,7 +10,17 @@ const FINDMNT_COMMON_OPTIONS = [
"--nofsroot", // prevents unwanted behavior with cifs volumes "--nofsroot", // prevents unwanted behavior with cifs volumes
]; ];
const DEFAULT_TIMEOUT = process.env.MOUNT_DEFAULT_TIMEOUT ? +process.env.MOUNT_DEFAULT_TIMEOUT : 3000; const DEFAULT_TIMEOUT = (() => {
const defaultValue = 30000;
if (process.env.MOUNT_DEFAULT_TIMEOUT) {
if (/^\d+$/.test(process.env.MOUNT_DEFAULT_TIMEOUT)) {
return parseInt(process.env.MOUNT_DEFAULT_TIMEOUT);
} else {
console.log("Invalid MOUNT_DEFAULT_TIMEOUT set: " + process.env.MOUNT_DEFAULT_TIMEOUT);
}
}
return defaultValue;
})()
class Mount { class Mount {
constructor(options = {}) { constructor(options = {}) {