@sanity/export 3.0.0-v3-pte.16 → 3.0.0-v3-pte.57
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.
- package/lib/AssetHandler.js +7 -8
- package/package.json +2 -2
- package/src/AssetHandler.js +9 -9
package/lib/AssetHandler.js
CHANGED
|
@@ -199,7 +199,7 @@ class AssetHandler {
|
|
|
199
199
|
const isImage = assetDoc._type === 'sanity.imageAsset';
|
|
200
200
|
const url = parseUrl(assetDoc.url, true);
|
|
201
201
|
|
|
202
|
-
if (isImage && ['cdn.sanity.io', 'cdn.sanity.work'].includes(url.hostname)) {
|
|
202
|
+
if (isImage && ['cdn.sanity.io', 'cdn.sanity.work'].includes(url.hostname) && token) {
|
|
203
203
|
headers.Authorization = "Bearer ".concat(token);
|
|
204
204
|
url.query = { ...(url.query || {}),
|
|
205
205
|
dlRaw: 'true'
|
|
@@ -253,14 +253,13 @@ class AssetHandler {
|
|
|
253
253
|
const remoteSha1 = stream.headers['x-sanity-sha1'];
|
|
254
254
|
const remoteMd5 = stream.headers['x-sanity-md5'];
|
|
255
255
|
const hasHash = Boolean(remoteSha1 || remoteMd5);
|
|
256
|
-
const method =
|
|
257
|
-
|
|
256
|
+
const method = sha1 ? 'sha1' : 'md5'; // Asset validity is primarily determined by the sha1 hash. However, the sha1 hash is computed
|
|
257
|
+
// before certain processes (i.e. svg sanitization) which can result in a different hash.
|
|
258
|
+
// When the sha1 hashes don't match, fallback to using the md5 hash.
|
|
258
259
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
differs = remoteSha1 !== sha1;
|
|
263
|
-
}
|
|
260
|
+
const sha1Differs = remoteSha1 && sha1 !== remoteSha1;
|
|
261
|
+
const md5Differs = remoteMd5 && md5 !== remoteMd5;
|
|
262
|
+
const differs = sha1Differs && md5Differs;
|
|
264
263
|
|
|
265
264
|
if (differs && attemptNum < 3) {
|
|
266
265
|
debug('%s does not match downloaded asset, retrying (#%d) [%s]', method, attemptNum + 1, url);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/export",
|
|
3
|
-
"version": "3.0.0-v3-pte.
|
|
3
|
+
"version": "3.0.0-v3-pte.57+7e5edfd5b4",
|
|
4
4
|
"description": "Export Sanity documents and assets",
|
|
5
5
|
"main": "./lib/export.js",
|
|
6
6
|
"types": "./lib/dts/src/export.d.ts",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"url": "https://github.com/sanity-io/sanity/issues"
|
|
50
50
|
},
|
|
51
51
|
"homepage": "https://www.sanity.io/",
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "7e5edfd5b4cef754b471f7d20f1d598ebf6532a1"
|
|
53
53
|
}
|
package/src/AssetHandler.js
CHANGED
|
@@ -125,7 +125,7 @@ class AssetHandler {
|
|
|
125
125
|
const isImage = assetDoc._type === 'sanity.imageAsset'
|
|
126
126
|
|
|
127
127
|
const url = parseUrl(assetDoc.url, true)
|
|
128
|
-
if (isImage && ['cdn.sanity.io', 'cdn.sanity.work'].includes(url.hostname)) {
|
|
128
|
+
if (isImage && ['cdn.sanity.io', 'cdn.sanity.work'].includes(url.hostname) && token) {
|
|
129
129
|
headers.Authorization = `Bearer ${token}`
|
|
130
130
|
url.query = {...(url.query || {}), dlRaw: 'true'}
|
|
131
131
|
}
|
|
@@ -168,14 +168,14 @@ class AssetHandler {
|
|
|
168
168
|
const remoteSha1 = stream.headers['x-sanity-sha1']
|
|
169
169
|
const remoteMd5 = stream.headers['x-sanity-md5']
|
|
170
170
|
const hasHash = Boolean(remoteSha1 || remoteMd5)
|
|
171
|
-
const method =
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
171
|
+
const method = sha1 ? 'sha1' : 'md5'
|
|
172
|
+
|
|
173
|
+
// Asset validity is primarily determined by the sha1 hash. However, the sha1 hash is computed
|
|
174
|
+
// before certain processes (i.e. svg sanitization) which can result in a different hash.
|
|
175
|
+
// When the sha1 hashes don't match, fallback to using the md5 hash.
|
|
176
|
+
const sha1Differs = remoteSha1 && sha1 !== remoteSha1
|
|
177
|
+
const md5Differs = remoteMd5 && md5 !== remoteMd5
|
|
178
|
+
const differs = sha1Differs && md5Differs
|
|
179
179
|
|
|
180
180
|
if (differs && attemptNum < 3) {
|
|
181
181
|
debug('%s does not match downloaded asset, retrying (#%d) [%s]', method, attemptNum + 1, url)
|