This commit is contained in:
syuilo
2018-04-10 04:02:25 +09:00
parent c7f322b327
commit ad18136b04
2 changed files with 13 additions and 19 deletions

View File

@@ -19,10 +19,10 @@ export default async (url, user, folderId = null, uri = null): Promise<IDriveFil
log(`name: ${name}`);
// Create temp file
const path = await new Promise<string>((res, rej) => {
tmp.file((e, path) => {
const [path, cleanup] = await new Promise<[string, any]>((res, rej) => {
tmp.file((e, path, fd, cleanup) => {
if (e) return rej(e);
res(path);
res([path, cleanup]);
});
});
@@ -44,9 +44,7 @@ export default async (url, user, folderId = null, uri = null): Promise<IDriveFil
log(`created: ${driveFile._id}`);
// clean-up
fs.unlink(path, e => {
if (e) console.error(e);
});
cleanup();
return driveFile;
};