@@ -207,22 +207,23 @@ void createDeltaForSingleFile(FileInfo targetFile, DirectoryInfo workingDirector
207207 this . Log ( ) . Warn ( "We couldn't create a delta for {0}, attempting to create bsdiff" , targetFile . Name ) ;
208208 }
209209 }
210-
211- var of = default ( FileStream ) ;
210+
212211 try {
213- of = File . Create ( targetFile . FullName + ".bsdiff" ) ;
214- BinaryPatchUtility . Create ( oldData , newData , of ) ;
215-
216- // NB: Create a dummy corrupt .diff file so that older
217- // versions which don't understand bsdiff will fail out
218- // until they get upgraded, instead of seeing the missing
219- // file and just removing it.
220- File . WriteAllText ( targetFile . FullName + ".diff" , "1" ) ;
212+ using ( FileStream of = File . Create ( targetFile . FullName + ".bsdiff" ) ) {
213+ BinaryPatchUtility . Create ( oldData , newData , of ) ;
214+
215+ // NB: Create a dummy corrupt .diff file so that older
216+ // versions which don't understand bsdiff will fail out
217+ // until they get upgraded, instead of seeing the missing
218+ // file and just removing it.
219+ File . WriteAllText ( targetFile . FullName + ".diff" , "1" ) ;
220+ }
221221 } catch ( Exception ex ) {
222222 this . Log ( ) . WarnException ( String . Format ( "We really couldn't create a delta for {0}" , targetFile . Name ) , ex ) ;
223+
224+ Utility . DeleteFileHarder ( targetFile . FullName + ".bsdiff" , true ) ;
225+ Utility . DeleteFileHarder ( targetFile . FullName + ".diff" , true ) ;
223226 return ;
224- } finally {
225- if ( of != null ) of . Dispose ( ) ;
226227 }
227228
228229 exit :
0 commit comments