Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copyToTemp() mkdirSync bug, should add recursive: true #271

Open
SteveCruise opened this issue Apr 26, 2023 · 2 comments
Open

copyToTemp() mkdirSync bug, should add recursive: true #271

SteveCruise opened this issue Apr 26, 2023 · 2 comments
Labels

Comments

@SteveCruise
Copy link

should add recursive: true
fs.mkdirSync(path.join(os.tmpdir(), 'screenCapture'), {recursive: true})

@pablohpsilva
Copy link

The following function dies if a screenshot was already taken. I suggest overwriting it or simply deleting before creating an image there. Also, a random name can be used.

function copyToTemp () {
  const tmpBat = path.join(os.tmpdir(), 'screenCapture', 'screenCapture_1.3.2.bat')
  const tmpManifest = path.join(os.tmpdir(), 'screenCapture', 'app.manifest')
  const includeBat = path.join(__dirname, 'screenCapture_1.3.2.bat').replace('app.asar', 'app.asar.unpacked')
  const includeManifest = path.join(__dirname, 'app.manifest').replace('app.asar', 'app.asar.unpacked')
  if (!fs.existsSync(tmpBat)) {
    fs.mkdirSync(path.join(os.tmpdir(), 'screenCapture'))
    const sourceData = {
      bat: fs.readFileSync(includeBat),
      manifest: fs.readFileSync(includeManifest)
    }
    fs.writeFileSync(tmpBat, sourceData.bat)
    fs.writeFileSync(tmpManifest, sourceData.manifest)
  }
  return tmpBat
}

@pablohpsilva
Copy link

pablohpsilva commented Apr 30, 2023

Error occurred in handler for 'smallAreaScreenShot': Error: ENOENT: no such file or directory, open 'C:\Users\admin\Documents\booo\.webpack\main\screenCapture_1.3.2.bat'
    at Object.openSync (node:fs:600:3)
    at Object.func [as openSync] (node:electron/js2c/asar_bundle:2:1822)
    at Object.readFileSync (node:fs:468:35)
    at t.readFileSync (node:electron/js2c/asar_bundle:2:9165)
    at copyToTemp (C:\Users\admin\Documents\booo\.webpack\main\index.js:56790:15)
    at C:\Users\admin\Documents\booo\.webpack\main\index.js:56810:20
    at new Promise (<anonymous>)
    at windowsSnapshot (C:\Users\admin\Documents\booo\.webpack\main\index.js:56800:10)
    at $c550fd30f5174fcd$export$ed45beb1e325e9b (C:\Users\admin\Documents\booo\.webpack\main\index.js:19138:74)   
    at C:\Users\admin\Documents\booo\.webpack\main\index.js:74228:72 {
  errno: -4058,
  syscall: 'open',
  code: 'ENOENT',
  path: 'C:\\Users\\admin\\Documents\\booo\\.webpack\\main\\screenCapture_1.3.2.bat'
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants