@@ -13,20 +13,16 @@ public static void Run(string repo, string revision, string file, string saveTo)
13
13
var isLFSFiltered = new IsLFSFiltered ( repo , revision , file ) . Result ( ) ;
14
14
if ( isLFSFiltered )
15
15
{
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 ) ;
22
18
}
23
19
else
24
20
{
25
21
ExecCmd ( repo , $ "show { revision } :\" { file } \" ", saveTo ) ;
26
22
}
27
23
}
28
24
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 )
30
26
{
31
27
var starter = new ProcessStartInfo ( ) ;
32
28
starter . WorkingDirectory = repo ;
@@ -45,21 +41,8 @@ private static bool ExecCmd(string repo, string args, string outputFile, string
45
41
{
46
42
var proc = new Process ( ) { StartInfo = starter } ;
47
43
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 ( ) ) ;
63
46
proc . StandardOutput . BaseStream . CopyTo ( sw ) ;
64
47
proc . WaitForExit ( ) ;
65
48
var rs = proc . ExitCode == 0 ;
0 commit comments