@@ -124,7 +124,7 @@ exports.post = function*() {
124124 // error, so delete all tmp files
125125 for ( var i = 0 ; i < files . length ; i ++ ) {
126126 var file = files [ i ] ;
127- fs . unlinkSync ( file . path ) ;
127+ yield fs . unlink ( file . path ) ;
128128 }
129129 this . addFlashMessage ( 'error' , e . message ) ;
130130 this . redirect ( this . originalUrl ) ;
@@ -142,7 +142,7 @@ exports.post = function*() {
142142 for ( let i = 0 ; i < files . length ; i ++ ) {
143143 let file = files [ i ] ;
144144 let originalFilename = transliterate ( file . originalFilename ) . replace ( / [ ^ \d \w _ . - ] / gim, '' ) ;
145- fs . renameSync ( file . path , path . join ( archiveDir , originalFilename ) ) ;
145+ yield * move ( file . path , path . join ( archiveDir , originalFilename ) ) ;
146146 this . log . debug ( "Moved to archive" , file . path , '->' , path . join ( archiveDir , originalFilename ) ) ;
147147 }
148148
@@ -153,7 +153,7 @@ exports.post = function*() {
153153 fse . ensureDir ( path . dirname ( filePath ) , callback ) ;
154154 } ;
155155
156- fs . renameSync ( processedMaterialsZip , filePath ) ;
156+ yield * move ( processedMaterialsZip , filePath ) ;
157157
158158 this . log . debug ( "Moved zipped result to" , filePath ) ;
159159
@@ -281,3 +281,10 @@ function* processFiles(name, files) {
281281 return workingDir + '.zip' ;
282282
283283}
284+
285+ function * move ( src , dst ) {
286+ yield function ( callback ) {
287+ fse . copy ( src , dst , callback ) ;
288+ } ;
289+ yield fs . unlink ( src ) ;
290+ }
0 commit comments