Skip to content

Commit 61e8923

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 0643ea0 + 6b6b0fa commit 61e8923

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

ImageCacheProvider.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,21 @@ function deleteMultipleCachedImages(urls, options = defaultOptions) {
274274
);
275275
}
276276

277+
/**
278+
* Seed the cache of a specified url with a local image
279+
* Handy if you have a local copy of a remote image, e.g. you just uploaded local to url.
280+
* @param local
281+
* @param url
282+
* @param options
283+
* @returns {Promise}
284+
*/
285+
function seedCache(local, url, options = defaultOptions) {
286+
const filePath = getCachedImageFilePath(url, options);
287+
const dirPath = getDirPath(filePath);
288+
return ensurePath(dirPath)
289+
.then(() => fs.cp(local, filePath))
290+
}
291+
277292
/**
278293
* Clear the entire cache.
279294
* @returns {Promise}
@@ -311,5 +326,6 @@ module.exports = {
311326
cacheMultipleImages,
312327
deleteMultipleCachedImages,
313328
clearCache,
329+
seedCache,
314330
getCacheInfo
315331
};

0 commit comments

Comments
 (0)