@@ -4,7 +4,6 @@ import { createTask, db, Task } from "./models";
44import { TaskResults } from "./task-results" ;
55import { TaskStatus } from "./models" ;
66import { NDJSONWriteStream } from "./ndjson"
7- import { _has } from 'botasaurus/cache'
87import { isLargeFile , isNoentError } from './utils'
98import { normalizeData , normalizeItem } from 'botasaurus/output'
109
@@ -33,26 +32,30 @@ function createKeyToNullMapping(newLocal: any): any {
3332 return acc
3433 } , { } )
3534}
36- function deleteFile ( filePath : string ) {
35+ // @ts -ignore
36+ function deleteFile ( filePath : string ) {
3737 if ( fs . existsSync ( filePath ) ) {
38- try {
39- fs . unlinkSync ( filePath ) ;
40- } catch ( error ) {
41- console . error ( "faced error while removing" )
42- console . error ( error )
43- // Ignore error
44- }
45- }
38+ return new Promise ( ( resolve , reject ) => {
39+ fs . unlink ( filePath , ( err ) => {
40+ if ( err ) {
41+ return reject ( err ) ;
42+ }
43+ // @ts -ignore
44+ resolve ( ) ;
45+ } ) ;
46+ } ) ;
47+
48+ }
4649}
47-
50+
4851async function moveFile ( tempFilePath : string , taskFilePath : string ) {
4952 try {
5053 await renameTemporaryFile ( tempFilePath , taskFilePath )
5154 } catch ( error : any ) {
5255 if ( isNoentError ( error ) ) {
5356 throw error
5457 }
55- deleteFile ( taskFilePath )
58+ await deleteFile ( taskFilePath )
5659 await renameTemporaryFile ( tempFilePath , taskFilePath )
5760 }
5861}
@@ -726,11 +729,7 @@ class TaskHelper {
726729 ...await TaskHelper . getSummaryTaskName ( parentId ) ,
727730 }
728731 if ( shouldFinish ) {
729- const now_date = new Date ( )
730- taskUpdateDetails [ 'finished_at' ] = now_date
731-
732- } else {
733- // this flow ran by cache completeion
732+ taskUpdateDetails [ 'finished_at' ] = new Date ( )
734733 }
735734
736735 return this . updateTask ( parentId , taskUpdateDetails )
0 commit comments