Skip to content

Commit c863005

Browse files
Fix for "open in colab" opens the same zip after updates (#295)
* Check if hyperlink is causing the problem - Perhaps the reactivity of vue is the problem and the hyperlink is not being updated * Change unique identifier each time the function is called * Revert back changes in NavColab.vue * Added combined hash of the code for formation of uuid * Fix lint * Using the uuidv5 URL namespace * Remove unwanted comments * Remove rogue extra line
1 parent e039b47 commit c863005

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

functions/colab.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
// `external_node_modules` of [functions] in netlify.toml
33
// They are required for this function to run
44

5-
import { v4 as uuidv4 } from 'uuid'
5+
import { v5 as uuidv5 } from 'uuid'
66
import JSZip from 'jszip'
77
import { pushToGitHub } from './utils'
88

9-
const nbUid = uuidv4()
109
const repoOwner = process.env.VUE_APP_GH_USER
1110
const repo = process.env.VUE_APP_GH_REPO
1211

@@ -17,6 +16,7 @@ exports.handler = async function (event, _) {
1716
const data = JSON.parse(event.body)
1817
const zip = new JSZip()
1918
const code = data.code
19+
let hash = ''
2020
const template = `ignite-${data.template}`
2121
const nbName = `${template}.ipynb`
2222

@@ -25,8 +25,10 @@ exports.handler = async function (event, _) {
2525
// generate a base64 format for pushing to GitHub
2626
// with Octokit.
2727
for (const filename in code) {
28+
hash += code[filename]
2829
zip.file(filename, code[filename])
2930
}
31+
const nbUid = uuidv5(hash, uuidv5.URL)
3032
const content = await zip.generateAsync({ type: 'base64' })
3133
const zipRes = await pushToGitHub(
3234
content,

0 commit comments

Comments
 (0)