@kne/fastify-puppeteer 1.1.4 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,13 +20,13 @@ module.exports = async options => {
20
20
  console.log('init cache dir');
21
21
  return {
22
22
  setCache: async (object, file) => {
23
- const hash = objectHash(object);
23
+ const objectHashValue = objectHash(object);
24
24
  if (Buffer.isBuffer(file)) {
25
25
  const {ext} = await fileType.fromBuffer(file);
26
26
  const filename = crypto.createHash('md5').update(file).digest('hex') + '.' + ext;
27
27
  const filePath = path.resolve(options.root, filename);
28
28
  await fs.writeFile(filePath, file);
29
- cache.set(hash, filename);
29
+ cache.set(objectHashValue, filename);
30
30
  return filename;
31
31
  } else {
32
32
  const filename = uuidv4() + '.zip';
@@ -41,8 +41,8 @@ module.exports = async options => {
41
41
  });
42
42
  const newFilename = hash.digest('hex') + '.zip';
43
43
  const newFilePath = path.resolve(options.root, newFilename);
44
- await fs.move(filePath, newFilePath);
45
- cache.set(hash, newFilename);
44
+ await fs.move(filePath, newFilePath, {overwrite: true});
45
+ cache.set(objectHashValue, newFilename);
46
46
  return newFilename;
47
47
  }
48
48
  }, getCache: async object => {
package/libs/services.js CHANGED
@@ -13,9 +13,9 @@ module.exports = fp(async (fastify, options) => {
13
13
  const deferred = createDeferred(maxConcurrent);
14
14
 
15
15
  const memoCache = (cacheName, callback) => async props => {
16
- const inputProps = Object.assign({}, props, { cacheName });
16
+ const { force, ...inputProps } = Object.assign({}, props, { cacheName });
17
17
  const currentCache = await cache.getCache(inputProps);
18
- if (currentCache && !inputProps.force) {
18
+ if (currentCache && !force) {
19
19
  return currentCache;
20
20
  }
21
21
  const output = await callback(props);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kne/fastify-puppeteer",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "用于操作无头浏览器截图保存pdf等",
5
5
  "main": "index.js",
6
6
  "scripts": {