Skip to content

Commit

Permalink
use our src cache preferentially
Browse files Browse the repository at this point in the history
  • Loading branch information
jhheider committed Oct 5, 2022
1 parent a4e2c7a commit de7cb7f
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/hooks/useCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ const download = async (opts: DownloadOptions) => {
const { download } = useDownload()

const { type } = opts
let url: URL
if (type == 'bottle') {
url = useOffLicense('s3').url({ pkg: opts.pkg, type: 'bottle', compression: 'gz' })
} else {
url = opts.url
}

const headers: HeadersInit = {}
let dst: Path | undefined
Expand All @@ -39,13 +33,28 @@ const download = async (opts: DownloadOptions) => {
dst = path({ pkg: opts.pkg, type: 'bottle', compression: 'gz' })
break
case 'src': {
const extname = new Path(url.pathname).extname()
const extname = opts.url.path().extname()
dst = path({ pkg: opts.pkg, type: 'src', extname })
} break
case 'script':
dst = undefined
}

let url: URL
if (type == 'bottle') {
url = useOffLicense('s3').url({ pkg: opts.pkg, type: 'bottle', compression: 'gz' })
} else if(type == 'src') {
const extname = opts.url.path().extname()
url = useOffLicense('s3').url({ pkg: opts.pkg, type: 'src', extname })
try {
return await download({ src: url, dst, headers })
} catch {
url = opts.url
}
} else {
url = opts.url
}

return await download({ src: url, dst, headers })
}

Expand Down

0 comments on commit de7cb7f

Please sign in to comment.