-
Notifications
You must be signed in to change notification settings - Fork 376
Check zstd is on the path in addition to tar version #2526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,20 @@ export type TarVersion = { | |
version: string; | ||
}; | ||
|
||
async function isBinaryAccessible( | ||
binary: string, | ||
logger: Logger, | ||
): Promise<boolean> { | ||
try { | ||
await safeWhich(binary); | ||
logger.debug(`Found ${binary}.`); | ||
return true; | ||
} catch (e) { | ||
logger.debug(`Could not find ${binary}: ${e}`); | ||
return false; | ||
} | ||
} | ||
|
||
async function getTarVersion(): Promise<TarVersion> { | ||
const tar = await safeWhich("tar"); | ||
let stdout = ""; | ||
|
@@ -53,36 +67,40 @@ async function getTarVersion(): Promise<TarVersion> { | |
|
||
export interface ZstdAvailability { | ||
available: boolean; | ||
foundZstdBinary: boolean; | ||
version?: TarVersion; | ||
} | ||
|
||
export async function isZstdAvailable( | ||
logger: Logger, | ||
): Promise<ZstdAvailability> { | ||
const foundZstdBinary = await isBinaryAccessible("zstd", logger); | ||
try { | ||
const tarVersion = await getTarVersion(); | ||
const { type, version } = tarVersion; | ||
logger.info(`Found ${type} tar version ${version}.`); | ||
switch (type) { | ||
case "gnu": | ||
return { | ||
available: version >= MIN_REQUIRED_GNU_TAR_VERSION, | ||
available: foundZstdBinary && version >= MIN_REQUIRED_GNU_TAR_VERSION, | ||
foundZstdBinary, | ||
version: tarVersion, | ||
}; | ||
case "bsd": | ||
return { | ||
available: version >= MIN_REQUIRED_BSD_TAR_VERSION, | ||
available: foundZstdBinary && version >= MIN_REQUIRED_BSD_TAR_VERSION, | ||
foundZstdBinary, | ||
version: tarVersion, | ||
}; | ||
default: | ||
assertNever(type); | ||
} | ||
} catch (e) { | ||
logger.error( | ||
logger.warning( | ||
"Failed to determine tar version, therefore will assume zstd may not be available. " + | ||
`The underlying error was: ${e}`, | ||
); | ||
return { available: false }; | ||
return { available: false, foundZstdBinary }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the use case for knowing if zstd is available if we can't figure out what tar version is available? Actually, I'm not sure what the use case for having There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If we can't figure out what tar version is available, we want to fall back to gzip.
Yes, this is just to help us understand how much of the time zstd wasn't available due to the tar version and how much of the time it wasn't available due to not being able to find a zstd binary. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it. |
||
} | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.