@@ -24,7 +24,7 @@ function getSubmissionDone(e, msg, problem, cb) {
24
24
console . log ( sprintf ( '[%3d] %-60s %s' ,
25
25
problem . id ,
26
26
problem . name ,
27
- ( e ? chalk . red ( 'ERROR: ' + e ) : chalk . yellow . underline ( msg ) )
27
+ ( e ? chalk . red ( 'ERROR: ' + e ) : msg )
28
28
) ) ;
29
29
if ( cb ) cb ( e ) ;
30
30
}
@@ -45,14 +45,22 @@ function getSubmission(problem, cb) {
45
45
// if no accepted, use the latest non-accepted one
46
46
submission = submission || submissions [ 0 ] ;
47
47
48
+ var filename = sprintf ( '%s.%s.%s%s' ,
49
+ problem . key ,
50
+ submission . id ,
51
+ problem . state ,
52
+ h . langToExt ( submission . lang ) ) ;
53
+
54
+ // skip the existing cached submissions
55
+ if ( fs . existsSync ( filename ) ) {
56
+ return done ( null , chalk . underline ( filename ) ) ;
57
+ }
58
+
48
59
core . getSubmission ( submission , function ( e , submission ) {
49
60
if ( e ) return done ( e ) ;
50
61
51
- var f = sprintf ( '%s.%s.%s%s' , problem . key , submission . id ,
52
- problem . state , h . langToExt ( submission . lang ) ) ;
53
- fs . writeFileSync ( f , submission . code ) ;
54
-
55
- done ( null , f ) ;
62
+ fs . writeFileSync ( filename , submission . code ) ;
63
+ done ( null , chalk . yellow . underline ( filename ) ) ;
56
64
} ) ;
57
65
} ) ;
58
66
}
0 commit comments