Remove dependency on node require for startup code path (#130088)

* sandbox - disable support to enable file protocol

* mitigate symlinks on different drives
This commit is contained in:
Benjamin Pasero
2021-08-04 10:45:11 +02:00
committed by GitHub
parent 53c3a2297b
commit b6ca3e52ae
14 changed files with 74 additions and 179 deletions

View File

@@ -18,7 +18,6 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { process } from 'vs/base/parts/sandbox/electron-sandbox/globals';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
import { isPreferringBrowserCodeLoad } from 'vs/base/common/platform';
import { IProductService } from 'vs/platform/product/common/productService';
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
@@ -99,37 +98,17 @@ export function didUseCachedData(productService: IProductService, storageService
// browser code loading: only a guess based on
// this being the first start with the commit
// or subsequent
if (isPreferringBrowserCodeLoad) {
if (typeof _didUseCachedData !== 'boolean') {
if (!environmentService.configuration.codeCachePath || !productService.commit) {
_didUseCachedData = false; // we only produce cached data whith commit and code cache path
} else if (storageService.get(lastRunningCommitStorageKey, StorageScope.GLOBAL) === productService.commit) {
_didUseCachedData = true; // subsequent start on same commit, assume cached data is there
} else {
storageService.store(lastRunningCommitStorageKey, productService.commit, StorageScope.GLOBAL, StorageTarget.MACHINE);
_didUseCachedData = false; // first time start on commit, assume cached data is not yet there
}
}
return _didUseCachedData;
}
// node.js code loading: We surely don't use cached data
// when we don't tell the loader to do so
if (!Boolean((<any>window).require.getConfig().nodeCachedData)) {
return false;
}
// There are loader events that signal if cached data was missing, rejected,
// or used. The former two mean no cached data.
let cachedDataFound = 0;
for (const event of require.getStats()) {
switch (event.type) {
case LoaderEventType.CachedDataRejected:
return false;
case LoaderEventType.CachedDataFound:
cachedDataFound += 1;
break;
if (typeof _didUseCachedData !== 'boolean') {
if (!environmentService.configuration.codeCachePath || !productService.commit) {
_didUseCachedData = false; // we only produce cached data whith commit and code cache path
} else if (storageService.get(lastRunningCommitStorageKey, StorageScope.GLOBAL) === productService.commit) {
_didUseCachedData = true; // subsequent start on same commit, assume cached data is there
} else {
storageService.store(lastRunningCommitStorageKey, productService.commit, StorageScope.GLOBAL, StorageTarget.MACHINE);
_didUseCachedData = false; // first time start on commit, assume cached data is not yet there
}
}
return cachedDataFound > 0;
return _didUseCachedData;
}
//#endregion