@@ -24,7 +24,7 @@ function getSubmissionDone(e, msg, problem, cb) {
2424 console . log ( sprintf ( '[%3d] %-60s %s' ,
2525 problem . id ,
2626 problem . name ,
27- ( e ? chalk . red ( 'ERROR: ' + e ) : chalk . yellow . underline ( msg ) )
27+ ( e ? chalk . red ( 'ERROR: ' + e ) : msg )
2828 ) ) ;
2929 if ( cb ) cb ( e ) ;
3030}
@@ -45,14 +45,22 @@ function getSubmission(problem, cb) {
4545 // if no accepted, use the latest non-accepted one
4646 submission = submission || submissions [ 0 ] ;
4747
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+
4859 core . getSubmission ( submission , function ( e , submission ) {
4960 if ( e ) return done ( e ) ;
5061
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 ) ) ;
5664 } ) ;
5765 } ) ;
5866}
0 commit comments