Skip to content

Commit 53909a2

Browse files
committed
fix: redownload files if actual file on Contentful changed
1 parent c61df86 commit 53909a2

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

packages/gatsby-transformer-video/src/ffmpeg.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,16 @@ export default class FFMPEG {
106106
}
107107

108108
if (type === `ContentfulAsset`) {
109-
path = await cacheContentfulVideo({
110-
video,
111-
cacheDir: this.cacheDirOriginal,
112-
})
113109
contentDigest = createContentDigest([
114110
video.contentful_id,
115111
video.file.url,
116112
video.file.details.size,
117113
])
114+
path = await cacheContentfulVideo({
115+
video,
116+
contentDigest,
117+
cacheDir: this.cacheDirOriginal,
118+
})
118119
}
119120

120121
if (!path) {

packages/gatsby-transformer-video/src/helpers.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import fs from "fs"
22
import { access } from "fs-extra"
3-
import { resolve } from "path"
3+
import { resolve, extname } from "path"
44

55
import PQueue from "p-queue"
66
import axios from "axios"
@@ -18,12 +18,12 @@ const downloadCache = {}
1818
* Retry is currently broken: https://github.com/gatsbyjs/gatsby/issues/22010
1919
* Downloaded files are not cached properly: https://github.com/gatsbyjs/gatsby/issues/8324 & https://github.com/gatsbyjs/gatsby/pull/8379
2020
*/
21-
export async function cacheContentfulVideo({ video, cacheDir }) {
21+
export async function cacheContentfulVideo({ video, cacheDir, contentDigest }) {
2222
const {
2323
file: { url, fileName },
2424
} = video
2525

26-
const path = resolve(cacheDir, fileName)
26+
const path = resolve(cacheDir, `${contentDigest}.${extname(fileName)}`)
2727

2828
try {
2929
await access(path, fs.constants.R_OK)

0 commit comments

Comments
 (0)