Skip to content

Commit ef156f6

Browse files
PR to improve the hash function for uuid (#312)
* Added time for calculating overhead * Added a the whole code for generating the hash * Modify to give output in milliseconds of only the hashing function * Revert to previous to test time * Fix typo * Improved uuid hashing by concatenating full code of a single template --------- Co-authored-by: vfdev <[email protected]>
1 parent 8dfacce commit ef156f6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

functions/utils.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,21 @@ export async function getZip_Uid(data) {
6363
const zip = new JSZip()
6464
const code = data.code
6565
const template = `ignite-${data.template}`
66+
let fullCode = ''
6667

6768
// As usual from Download component,
6869
// we will zip the files and
6970
// generate a base64 format for pushing to GitHub
7071
// with Octokit.
7172
for (const filename in code) {
73+
fullCode += code[filename]
7274
zip.file(filename, code[filename])
7375
}
7476
// since the generated zip varies every time even with the same code
7577
// it can't be used to generate a UUID
7678
const content = await zip.generateAsync({ type: 'base64' })
7779
// we generate an unique id from the current config for pushing to github
78-
const nbUid = uuidv5(JSON.stringify(data.config), uuidv5.URL)
80+
const nbUid = uuidv5(fullCode, uuidv5.URL)
7981
const zipRes = await pushToGitHub(content, `${template}.zip`, nbUid)
8082
return {
8183
zipRes: zipRes,

0 commit comments

Comments
 (0)