Fixed async logic within lib/file_ops.js

This commit is contained in:
jake87 committed 2021-10-26 20:46:24 +11:00
1 parent ed73e3ad1e
commit f266c441db
1 file changed
+4 -3
+4 -3
View File
@@ -72,10 +72,11 @@ async function findUnusedName(directory, name, extension = "") {
async function getTempFile(prefix, suffix, tmpdir) {
prefix = (typeof prefix !== "undefined") ? prefix : "tmp.";
suffix = (typeof suffix !== "undefined") ? suffix : "";
tmpdir = tmpdir ? tmpdir : os.tmpdir();
tmpdir = (typeof tmpdir !== "undefined") ? tmpdir : "./";
let fileName = path.join(prefix + crypto.randomBytes(16).toString("hex") + suffix);
let fullPath = path.join(tmpdir, findUnusedName(tmpdir, fullname));
return fullpath;
let freeFile = await findUnusedName(tmpdir, fileName);
let fullPath = path.join(tmpdir, freeFile);
return fullPath;
}
module.exports = {