Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,25 @@ const restoreCache = (cachePath: string, cacheKey: string) => {
})
}

const generateEnvironmentKey = (options: Options, prefix: string) => {
const generateEnvironmentKey = async (options: Options, prefix: string) => {
const arch = `-${getCondaArch()}`
const envName = options.environmentName ? `-${options.environmentName}` : ''
const createArgs = options.createArgs ? `-args-${sha256Short(JSON.stringify(options.createArgs))}` : ''
const rootPrefix = `-root-${sha256Short(options.micromambaRootPath)}`
const binHash = fs.readFile(options.micromambaBinPath).then(sha256)
const binHash = await fs.readFile(options.micromambaBinPath, 'utf-8').then(sha256)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading this binary executable as UTF-8 seems wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great point, wasn't thinking. Should just hash as bytes


const key = `${prefix}${arch}${envName}${createArgs}${rootPrefix}-bin-${binHash}`

if (options.environmentFile) {
return fs.readFile(options.environmentFile, 'utf-8').then((content) => {
return await fs.readFile(options.environmentFile, 'utf-8').then((content) => {
const keyWithFileSha = `${key}-file-${sha256(content)}`
core.debug(`Generated key \`${keyWithFileSha}\`.`)
return keyWithFileSha
})
}

core.debug(`Generated key \`${key}\`.`)
return Promise.resolve(key)
return key
}

const generateDownloadsKey = (prefix: string) => `${prefix}-${getCondaArch()}`
Expand Down
Loading