File tree Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -5,11 +5,9 @@ const { DateCompare } = require("@11ty/eleventy-utils");
5
5
6
6
const FileCache = require ( "./FileCache.js" ) ;
7
7
const Sources = require ( "./Sources.js" ) ;
8
- const DirectoryManager = require ( "./DirectoryManager.js" ) ;
9
8
10
9
const debugUtil = require ( "debug" ) ;
11
10
const debug = debugUtil ( "Eleventy:Fetch" ) ;
12
- const debugAssets = debugUtil ( "Eleventy:Assets" ) ;
13
11
14
12
class AssetCache {
15
13
#source;
@@ -19,7 +17,6 @@ class AssetCache {
19
17
#cacheDirectory;
20
18
#cacheLocationDirty = false ;
21
19
#directoryManager;
22
- #rawContents = { } ;
23
20
24
21
constructor ( source , cacheDirectory , options = { } ) {
25
22
if ( ! Sources . isValidSource ( source ) ) {
@@ -227,12 +224,15 @@ class AssetCache {
227
224
}
228
225
229
226
isCacheValid ( duration = this . duration ) {
230
- if ( ! this . cachedObject || ! this . cachedObject . cachedAt ) {
231
- // not cached
227
+ if ( ! this . cachedObject || ! this . cachedObject ?. cachedAt ) {
232
228
return false ;
233
229
}
234
230
235
- return DateCompare . isTimestampWithinDuration ( this . cachedObject . cachedAt , duration ) ;
231
+ if ( DateCompare . isTimestampWithinDuration ( this . cachedObject ?. cachedAt , duration ) ) {
232
+ return this . cache . hasContents ( ) ; // check file system to make files haven’t been purged.
233
+ }
234
+
235
+ return false ;
236
236
}
237
237
238
238
get cachedObject ( ) {
Original file line number Diff line number Diff line change @@ -131,6 +131,18 @@ class FileCache {
131
131
return Buffer . from ( rawData . contents ) ;
132
132
}
133
133
134
+ hasContents ( ) {
135
+ if ( this . #contents) {
136
+ return true ;
137
+ }
138
+ if ( ! this . isSideLoaded ( ) && this . get ( ) ?. data ) {
139
+ return true ;
140
+ } else if ( this . get ( ) ?. contents ) {
141
+ return true ;
142
+ }
143
+ return existsCache . exists ( this . contentsPath ) ;
144
+ }
145
+
134
146
getContents ( ) {
135
147
if ( this . #contents) {
136
148
return this . #contents;
You can’t perform that action at this time.
0 commit comments