Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
nchaulet committed Oct 31, 2024
1 parent 27c3f48 commit ea89b50
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions x-pack/plugins/fleet/server/services/epm/packages/remove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,18 @@ const MAX_ASSETS_TO_DELETE = 1000;
export async function removeInstallation(options: {
savedObjectsClient: SavedObjectsClientContract;
pkgName: string;
pkgVersion: string;
pkgVersion?: string;
esClient: ElasticsearchClient;
force?: boolean;
}): Promise<AssetReference[]> {
const { savedObjectsClient, pkgName, pkgVersion, esClient } = options;
const installation = await getInstallation({ savedObjectsClient, pkgName });
if (!installation) throw new PackageRemovalError(`${pkgName} is not installed`);

if (!installation) {
throw new PackageRemovalError(`${pkgName} is not installed`);
}
if (pkgVersion && installation.version !== pkgVersion) {
throw new PackageRemovalError(`${pkgName} ${pkgVersion} is not installed`);
}
const { total, items } = await packagePolicyService.list(
appContextService.getInternalUserSOClientWithoutSpaceExtension(),
{
Expand Down Expand Up @@ -115,7 +119,7 @@ export async function removeInstallation(options: {
// a fresh copy from the registry
deletePackageCache({
name: pkgName,
version: pkgVersion,
version: installation.version,
});

await removeArchiveEntries({ savedObjectsClient, refs: installation.package_assets });
Expand Down

0 comments on commit ea89b50

Please sign in to comment.