@@ -101,11 +101,7 @@ const imageCacheHoc = <P extends object>(
101
101
* @returns {Promise } promise that resolves to an object that contains cached file info.
102
102
*/
103
103
static async cacheFile ( url : string ) : Promise < any > {
104
- const fileSystem = FileSystemFactory (
105
- options . cachePruneTriggerLimit || null ,
106
- options . fileDirName || null ,
107
- )
108
- const localFilePath = await fileSystem . getLocalFilePathFromUrl ( url )
104
+ const localFilePath = await this . fileSystem ( ) . getLocalFilePathFromUrl ( url )
109
105
110
106
return {
111
107
url : url ,
@@ -134,11 +130,7 @@ const imageCacheHoc = <P extends object>(
134
130
mtime ?: Date ,
135
131
ctime ?: Date ,
136
132
) {
137
- const fileSystem = FileSystemFactory (
138
- options . cachePruneTriggerLimit || null ,
139
- options . fileDirName || null ,
140
- )
141
- return fileSystem . cacheLocalFile ( local , url , move , mtime , ctime )
133
+ return this . fileSystem ( ) . cacheLocalFile ( local , url , move , mtime , ctime )
142
134
}
143
135
144
136
/**
@@ -149,12 +141,16 @@ const imageCacheHoc = <P extends object>(
149
141
* @returns {Promise } promise that resolves to an object that contains the flush results.
150
142
*/
151
143
static async flush ( ) {
152
- const fileSystem = FileSystemFactory (
153
- options . cachePruneTriggerLimit || null ,
154
- options . fileDirName || null ,
155
- )
144
+ return this . fileSystem ( ) . unlink ( '' )
145
+ }
156
146
157
- return fileSystem . unlink ( '' )
147
+ /**
148
+ * Export FileSystem for convenience.
149
+ *
150
+ * @returns {FileSystem }
151
+ */
152
+ static fileSystem ( ) {
153
+ return FileSystemFactory ( options . cachePruneTriggerLimit || null , options . fileDirName || null )
158
154
}
159
155
160
156
constructor ( props : P ) {
0 commit comments