@@ -120,47 +120,69 @@ const string
120120int CanSkipAnalyse ( )
121121{
122122 string cachePath = "cache.json" ;
123- DateTime libLastModified = File . GetLastWriteTime ( libPath ) ;
124123
125- if ( ! Directory . Exists ( siteDir + "articles" ) )
124+ DateTime
125+ libLastModified = File . GetLastWriteTime ( libPath ) ,
126+ docfxJsonLastModified = File . GetLastWriteTime ( configPath ) ;
127+
128+ if ( ! Directory . Exists ( siteDir + "api" ) )
126129 {
127130 WriteCache ( ) ;
128131 return 0 ;
129132 }
130133
131- if ( File . Exists ( cachePath ) )
134+ if ( ! File . Exists ( cachePath ) )
132135 {
133- string json ;
136+ WriteCache ( ) ;
137+ return 0 ;
138+ }
134139
135- try { json = File . ReadAllText ( cachePath ) ; }
136- catch ( Exception ex )
137- {
138- Console . WriteLine ( "Error reading build cache:" ) ;
139- Console . WriteLine ( ex ) ;
140+ string json ;
140141
141- return - 1 ;
142- }
142+ try { json = File . ReadAllText ( cachePath ) ; }
143+ catch ( Exception ex )
144+ {
145+ Console . WriteLine ( "Error reading build cache:" ) ;
146+ Console . WriteLine ( ex ) ;
143147
144- BuildCache ? cache ;
148+ return - 1 ;
149+ }
145150
146- try { cache = JsonSerializer . Deserialize < BuildCache > ( File . ReadAllText ( cachePath ) ) ; }
147- catch ( Exception ex )
148- {
149- Console . WriteLine ( "Error parsing build cache:" ) ;
150- Console . WriteLine ( ex ) ;
151+ BuildCache ? cache ;
151152
152- return - 1 ;
153- }
153+ try { cache = JsonSerializer . Deserialize < BuildCache > ( File . ReadAllText ( cachePath ) ) ; }
154+ catch ( Exception ex )
155+ {
156+ Console . WriteLine ( "Error parsing build cache:" ) ;
157+ Console . WriteLine ( ex ) ;
158+
159+ return - 1 ;
160+ }
161+
162+ if ( cache is null )
163+ {
164+ WriteCache ( ) ;
165+ return 0 ;
166+ }
154167
155- if ( cache is not null && cache . LibLastModified >= libLastModified )
156- return 1 ;
168+ if ( libLastModified > cache . LibLastModified )
169+ {
170+ WriteCache ( ) ;
171+ return 0 ;
172+ }
173+
174+ if ( docfxJsonLastModified > cache . DocfxJsonLastModified )
175+ {
176+ WriteCache ( ) ;
177+ return 0 ;
157178 }
158179
159- WriteCache ( ) ;
160- return 0 ;
180+ return 1 ;
161181
162182 void WriteCache ( )
163- => File . WriteAllText ( cachePath , JsonSerializer . Serialize ( new BuildCache ( libLastModified ) ) ) ;
183+ => File . WriteAllText ( cachePath , JsonSerializer . Serialize ( new BuildCache (
184+ LibLastModified : libLastModified ,
185+ DocfxJsonLastModified : docfxJsonLastModified ) ) ) ;
164186}
165187
166188bool ValidateEnv ( string env , string ? value )
@@ -180,4 +202,4 @@ static void PrintStatus(string status)
180202 Console . WriteLine ( ) ;
181203}
182204
183- record class BuildCache ( DateTime LibLastModified ) ;
205+ record class BuildCache ( DateTime LibLastModified , DateTime DocfxJsonLastModified ) ;
0 commit comments