From 6c29f57d61086ce3c67359d4da03f2d085b97692 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E7=8E=8B=E8=BD=B6?=
Date: Sat, 1 Feb 2020 15:22:59 +0800
Subject: [PATCH] Fix qiniu token refresh bug.
---
package.json | 7 +++----
src/lib/qiniu.js | 2 +-
yarn.lock | 28 ++--------------------------
3 files changed, 6 insertions(+), 31 deletions(-)
diff --git a/package.json b/package.json
index ce5ba33..d3ceac5 100644
--- a/package.json
+++ b/package.json
@@ -1,10 +1,10 @@
{
"name": "electron-distribution",
- "version": "1.0.2",
+ "version": "1.0.3",
"description": "Electron Distribution",
"author": "yi-ge ",
"scripts": {
- "dev": "cross-env NODE_ENV=development nodemon src/dev.js",
+ "dev": "nodemon src/dev.js",
"build": "babel src -d dist",
"start": "node dist/app.js"
},
@@ -15,7 +15,6 @@
"chalk": "^2.4.2",
"chance": "^1.0.18",
"cos-nodejs-sdk-v5": "^2.5.7",
- "cross-env": "^5.2.0",
"dockerode": "^2.5.8",
"hapi": "^18.1.0",
"hapi-swagger": "^9.4.2",
@@ -62,4 +61,4 @@
"engines": {
"node": ">= 10"
}
-}
\ No newline at end of file
+}
diff --git a/src/lib/qiniu.js b/src/lib/qiniu.js
index af58251..b5fd6e9 100644
--- a/src/lib/qiniu.js
+++ b/src/lib/qiniu.js
@@ -6,7 +6,6 @@ const mac = new qiniu.auth.digest.Mac(QINIU.accessKey, QINIU.secretKey)
const putPolicy = new qiniu.rs.PutPolicy({
scope: QINIU.bucket
})
-const uploadToken = putPolicy.uploadToken(mac)
const config = new qiniu.conf.Config()
// 空间对应的机房
@@ -18,6 +17,7 @@ config.useHttpsDomain = true
export const uploadLocalFileToQiniu = (key, localFile) => {
return new Promise((resolve, reject) => {
+ const uploadToken = putPolicy.uploadToken(mac)
var resumeUploader = new qiniu.resume_up.ResumeUploader(config)
var putExtra = new qiniu.resume_up.PutExtra()
// 如果指定了断点记录文件,那么下次会从指定的该文件尝试读取上次上传的进度,以实现断点续传
diff --git a/yarn.lock b/yarn.lock
index fddb939..50264f6 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1451,14 +1451,6 @@ create-error-class@^3.0.0:
dependencies:
capture-stack-trace "^1.0.0"
-cross-env@^5.2.0:
- version "5.2.0"
- resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-5.2.0.tgz#6ecd4c015d5773e614039ee529076669b9d126f2"
- integrity sha512-jtdNFfFW1hB7sMhr/H6rW1Z45LFqyI431m3qU6bFXcQ3Eh7LtBuG3h74o7ohHZ3crrRkkqHlo4jYHFPcjroANg==
- dependencies:
- cross-spawn "^6.0.5"
- is-windows "^1.0.0"
-
cross-spawn@^5.0.1:
version "5.1.0"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449"
@@ -1468,17 +1460,6 @@ cross-spawn@^5.0.1:
shebang-command "^1.2.0"
which "^1.2.9"
-cross-spawn@^6.0.5:
- version "6.0.5"
- resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4"
- integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==
- dependencies:
- nice-try "^1.0.4"
- path-key "^2.0.1"
- semver "^5.5.0"
- shebang-command "^1.2.0"
- which "^1.2.9"
-
cryptiles@4.x.x:
version "4.1.3"
resolved "https://registry.yarnpkg.com/cryptiles/-/cryptiles-4.1.3.tgz#2461d3390ea0b82c643a6ba79f0ed491b0934c25"
@@ -2549,7 +2530,7 @@ is-typedarray@~1.0.0:
resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a"
integrity sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=
-is-windows@^1.0.0, is-windows@^1.0.2:
+is-windows@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d"
integrity sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==
@@ -3032,11 +3013,6 @@ netmask@^1.0.6:
resolved "https://registry.yarnpkg.com/netmask/-/netmask-1.0.6.tgz#20297e89d86f6f6400f250d9f4f6b4c1945fcd35"
integrity sha1-ICl+idhvb2QA8lDZ9Pa0wZRfzTU=
-nice-try@^1.0.4:
- version "1.0.5"
- resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366"
- integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==
-
nigel@3.x.x:
version "3.0.4"
resolved "https://registry.yarnpkg.com/nigel/-/nigel-3.0.4.tgz#edcd82f2e9387fe34ba21e3127ae4891547c7945"
@@ -3363,7 +3339,7 @@ path-is-inside@^1.0.1:
resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53"
integrity sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=
-path-key@^2.0.0, path-key@^2.0.1:
+path-key@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40"
integrity sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=