Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const startup = () => Promise.all([
addProcessListeners(),
createDirectory(TMPDIR_FILES, PERM_DIR),
createDirectory(TMPDIR_FILES_PB, PERM_DIR),
]).then(exportAppStatus).catch(handleReject);
const initPrivateTmpDir = async bool => {
if (bool) {
fileMap[TMP_FILES_PB].clear();
await removeDirectory(TMPDIR_FILES_PB, TMPDIR);
await createDirectory(TMPDIR_FILES_PB, PERM_DIR);
}
};
const createTmpFile = async (obj = {}) => {
const {data, value} = obj;
let filePath;
if (data) {
const {
dataId, dir, extType, host, incognito, mode, syncAuto, tabId,
windowId,
} = data;
if (dataId && dir && extType && host && tabId && windowId) {
const dirPath = await createDirectory(
path.join(TMPDIR_APP, dir, windowId, tabId, host), PERM_DIR,
);
const fileId = [windowId, tabId, host, dataId].join("_");
const fileName = dataId && encodeURIComponent(dataId);
filePath = dirPath && fileName && extType &&
await createFile(path.join(dirPath, fileName + extType), value,
{encoding: CHAR, flag: "w", mode: PERM_FILE});
filePath && dir && fileMap[dir] &&
fileMap[dir].set(fileId, {data, filePath});
if (!incognito && mode === MODE_EDIT && syncAuto) {
const opt = {
persistent: true,
recursive: false,
encoding: CHAR,
};
fileMap[FILE_WATCH].set(filePath, watch(filePath, opt, watchTmpFile));