Tweaks to Java discovery.
Add AdoptOpenJDK directory to the file scan. Remove TLS reject unauthorized flag. Use async/await for the fs scan function. Code was originally wrote using fs and not fs-extra.
This commit is contained in:
parent
17e36fa5a2
commit
25e7e5aa55
@ -6,8 +6,6 @@ if(target == null){
|
|||||||
}
|
}
|
||||||
let tracker = new target(...(process.argv.splice(3)))
|
let tracker = new target(...(process.argv.splice(3)))
|
||||||
|
|
||||||
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'
|
|
||||||
|
|
||||||
//const tracker = new AssetGuard(process.argv[2], process.argv[3])
|
//const tracker = new AssetGuard(process.argv[2], process.argv[3])
|
||||||
console.log('AssetExec Started')
|
console.log('AssetExec Started')
|
||||||
|
|
||||||
|
@ -709,51 +709,26 @@ class JavaGuard extends EventEmitter {
|
|||||||
* @returns {Promise.<Set.<string>>} A promise which resolves to a set of the discovered
|
* @returns {Promise.<Set.<string>>} A promise which resolves to a set of the discovered
|
||||||
* root JVM folders.
|
* root JVM folders.
|
||||||
*/
|
*/
|
||||||
static _scanFileSystem(scanDir){
|
static async _scanFileSystem(scanDir){
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
|
|
||||||
fs.exists(scanDir, (e) => {
|
let res = new Set()
|
||||||
|
|
||||||
let res = new Set()
|
if(await fs.pathExists(scanDir)) {
|
||||||
|
|
||||||
if(e){
|
const files = await fs.readdir(scanDir)
|
||||||
fs.readdir(scanDir, (err, files) => {
|
for(let i=0; i<files.length; i++){
|
||||||
if(err){
|
|
||||||
resolve(res)
|
|
||||||
console.log(err)
|
|
||||||
} else {
|
|
||||||
let pathsDone = 0
|
|
||||||
|
|
||||||
for(let i=0; i<files.length; i++){
|
const combinedPath = path.join(scanDir, files[i])
|
||||||
|
const execPath = JavaGuard.javaExecFromRoot(combinedPath)
|
||||||
|
|
||||||
const combinedPath = path.join(scanDir, files[i])
|
if(await fs.pathExists(execPath)) {
|
||||||
const execPath = JavaGuard.javaExecFromRoot(combinedPath)
|
res.add(combinedPath)
|
||||||
|
|
||||||
fs.exists(execPath, (v) => {
|
|
||||||
|
|
||||||
if(v){
|
|
||||||
res.add(combinedPath)
|
|
||||||
}
|
|
||||||
|
|
||||||
++pathsDone
|
|
||||||
|
|
||||||
if(pathsDone === files.length){
|
|
||||||
resolve(res)
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if(pathsDone === files.length){
|
|
||||||
resolve(res)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
resolve(res)
|
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -859,9 +834,13 @@ class JavaGuard extends EventEmitter {
|
|||||||
|
|
||||||
// Get possible paths from the registry.
|
// Get possible paths from the registry.
|
||||||
let pathSet1 = await JavaGuard._scanRegistry()
|
let pathSet1 = await JavaGuard._scanRegistry()
|
||||||
if(pathSet1.length === 0){
|
if(pathSet1.size === 0){
|
||||||
// Do a manual file system scan of program files.
|
// Do a manual file system scan of program files.
|
||||||
pathSet1 = JavaGuard._scanFileSystem('C:\\Program Files\\Java')
|
pathSet1 = new Set([
|
||||||
|
...pathSet1,
|
||||||
|
...(await JavaGuard._scanFileSystem('C:\\Program Files\\Java')),
|
||||||
|
...(await JavaGuard._scanFileSystem('C:\\Program Files\\AdoptOpenJDK'))
|
||||||
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get possible paths from the data directory.
|
// Get possible paths from the data directory.
|
||||||
|
Loading…
Reference in New Issue
Block a user