@@ -13,20 +13,16 @@ public static void Run(string repo, string revision, string file, string saveTo)
1313 var isLFSFiltered = new IsLFSFiltered ( repo , revision , file ) . Result ( ) ;
1414 if ( isLFSFiltered )
1515 {
16- var tmpFile = saveTo + ".tmp" ;
17- if ( ExecCmd ( repo , $ "show { revision } :\" { file } \" ", tmpFile ) )
18- {
19- ExecCmd ( repo , $ "lfs smudge", saveTo , tmpFile ) ;
20- }
21- File . Delete ( tmpFile ) ;
16+ var pointerStream = QueryFileContent . Run ( repo , revision , file ) ;
17+ ExecCmd ( repo , $ "lfs smudge", saveTo , pointerStream ) ;
2218 }
2319 else
2420 {
2521 ExecCmd ( repo , $ "show { revision } :\" { file } \" ", saveTo ) ;
2622 }
2723 }
2824
29- private static bool ExecCmd ( string repo , string args , string outputFile , string inputFile = null )
25+ private static bool ExecCmd ( string repo , string args , string outputFile , Stream input = null )
3026 {
3127 var starter = new ProcessStartInfo ( ) ;
3228 starter . WorkingDirectory = repo ;
@@ -45,21 +41,8 @@ private static bool ExecCmd(string repo, string args, string outputFile, string
4541 {
4642 var proc = new Process ( ) { StartInfo = starter } ;
4743 proc . Start ( ) ;
48-
49- if ( inputFile != null )
50- {
51- using ( StreamReader sr = new StreamReader ( inputFile ) )
52- {
53- while ( true )
54- {
55- var line = sr . ReadLine ( ) ;
56- if ( line == null )
57- break ;
58- proc . StandardInput . WriteLine ( line ) ;
59- }
60- }
61- }
62-
44+ if ( input != null )
45+ proc . StandardInput . Write ( new StreamReader ( input ) . ReadToEnd ( ) ) ;
6346 proc . StandardOutput . BaseStream . CopyTo ( sw ) ;
6447 proc . WaitForExit ( ) ;
6548 var rs = proc . ExitCode == 0 ;
0 commit comments