File tree Expand file tree Collapse file tree
x-pack/plugins/ingest_manager/server/services/epm Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33 * or more contributor license agreements. Licensed under the Elastic License;
44 * you may not use this file except in compliance with the Elastic License.
55 */
6- import { pkgToPkgKey } from './index' ;
6+ import { pkgToPkgKey } from '../registry /index' ;
77
88const cache : Map < string , Buffer > = new Map ( ) ;
99export const cacheGet = ( key : string ) => cache . get ( key ) ;
Original file line number Diff line number Diff line change 66
77import { ArchivePackage } from '../../../../common/types' ;
88import { PackageInvalidArchiveError , PackageUnsupportedMediaTypeError } from '../../../errors' ;
9- import { cacheSet , setArchiveFilelist } from '../registry/cache' ;
9+ import {
10+ cacheSet ,
11+ cacheDelete ,
12+ getArchiveFilelist ,
13+ setArchiveFilelist ,
14+ deleteArchiveFilelist ,
15+ } from './cache' ;
1016import { ArchiveEntry , getBufferExtractor } from '../registry/extract' ;
1117import { parseAndVerifyArchive } from './validation' ;
1218
19+ export * from './cache' ;
20+
1321export async function loadArchivePackage ( {
1422 archiveBuffer,
1523 contentType,
@@ -64,3 +72,15 @@ export async function unpackArchiveToCache(
6472 }
6573 return paths ;
6674}
75+
76+ export const deletePackageCache = ( name : string , version : string ) => {
77+ // get cached archive filelist
78+ const paths = getArchiveFilelist ( name , version ) ;
79+
80+ // delete cached archive filelist
81+ deleteArchiveFilelist ( name , version ) ;
82+
83+ // delete cached archive files
84+ // this has been populated in unpackArchiveToCache()
85+ paths ?. forEach ( ( path ) => cacheDelete ( path ) ) ;
86+ } ;
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ import {
1616} from '../../../../common/types' ;
1717import { PackageInvalidArchiveError } from '../../../errors' ;
1818import { pkgToPkgKey } from '../registry' ;
19- import { cacheGet } from '../registry /cache' ;
19+ import { cacheGet } from './cache' ;
2020
2121// TODO: everything below performs verification of manifest.yml files, and hence duplicates functionality already implemented in the
2222// package registry. At some point this should probably be replaced (or enhanced) with verification based on
Original file line number Diff line number Diff line change 66
77import { InstallablePackage } from '../../../types' ;
88import { getAssets } from './assets' ;
9- import { getArchiveFilelist } from '../registry /cache' ;
9+ import { getArchiveFilelist } from '../archive /cache' ;
1010
11- jest . mock ( '../registry /cache' , ( ) => {
11+ jest . mock ( '../archive /cache' , ( ) => {
1212 return {
1313 getArchiveFilelist : jest . fn ( ) ,
1414 } ;
Original file line number Diff line number Diff line change 66
77import { InstallablePackage } from '../../../types' ;
88import * as Registry from '../registry' ;
9- import { getArchiveFilelist } from '../registry /cache' ;
9+ import { getArchiveFilelist } from '../archive /cache' ;
1010
1111// paths from RegistryPackage are routes to the assets on EPR
1212// e.g. `/package/nginx/1.2.0/data_stream/access/fields/fields.yml`
Original file line number Diff line number Diff line change @@ -21,7 +21,8 @@ import { deletePipeline } from '../elasticsearch/ingest_pipeline/';
2121import { installIndexPatterns } from '../kibana/index_pattern/install' ;
2222import { deleteTransforms } from '../elasticsearch/transform/remove' ;
2323import { packagePolicyService , appContextService } from '../..' ;
24- import { splitPkgKey , deletePackageCache } from '../registry' ;
24+ import { splitPkgKey } from '../registry' ;
25+ import { deletePackageCache } from '../archive' ;
2526
2627export async function removeInstallation ( options : {
2728 savedObjectsClient : SavedObjectsClientContract ;
Original file line number Diff line number Diff line change @@ -19,13 +19,7 @@ import {
1919 RegistrySearchResult ,
2020} from '../../../types' ;
2121import { unpackArchiveToCache } from '../archive' ;
22- import {
23- cacheGet ,
24- cacheDelete ,
25- getArchiveFilelist ,
26- setArchiveFilelist ,
27- deleteArchiveFilelist ,
28- } from './cache' ;
22+ import { cacheGet , getArchiveFilelist , setArchiveFilelist } from '../archive' ;
2923import { ArchiveEntry } from './extract' ;
3024import { fetchUrl , getResponse , getResponseStream } from './requests' ;
3125import { streamToBuffer } from './streams' ;
@@ -247,15 +241,3 @@ export function groupPathsByService(paths: string[]): AssetsGroupedByServiceByTy
247241 // elasticsearch: assets.elasticsearch,
248242 } ;
249243}
250-
251- export const deletePackageCache = ( name : string , version : string ) => {
252- // get cached archive filelist
253- const paths = getArchiveFilelist ( name , version ) ;
254-
255- // delete cached archive filelist
256- deleteArchiveFilelist ( name , version ) ;
257-
258- // delete cached archive files
259- // this has been populated in unpackRegistryPackageToCache()
260- paths ?. forEach ( ( path ) => cacheDelete ( path ) ) ;
261- } ;
You can’t perform that action at this time.
0 commit comments