mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-22 09:35:37 -05:00
show notebook as trusted when it belongs to a trusted book (#15093)
* check for trusted books * don't add to trustedNotebooksMomento * update comment * added comments * remove empty line
This commit is contained in:
@@ -51,6 +51,7 @@ import { IEditorInput, IEditorPane } from 'vs/workbench/common/editor';
|
||||
import { isINotebookInput } from 'sql/workbench/services/notebook/browser/interface';
|
||||
import { INotebookShowOptions } from 'sql/workbench/api/common/sqlExtHost.protocol';
|
||||
import { NotebookLanguage } from 'sql/workbench/common/constants';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
|
||||
const languageAssociationRegistry = Registry.as<ILanguageAssociationRegistry>(LanguageAssociationExtensions.LanguageAssociations);
|
||||
|
||||
@@ -140,7 +141,8 @@ export class NotebookService extends Disposable implements INotebookService {
|
||||
@IProductService private readonly productService: IProductService,
|
||||
@IEditorService private _editorService: IEditorService,
|
||||
@IUntitledTextEditorService private _untitledEditorService: IUntitledTextEditorService,
|
||||
@IEditorGroupsService private _editorGroupService: IEditorGroupsService
|
||||
@IEditorGroupsService private _editorGroupService: IEditorGroupsService,
|
||||
@IConfigurationService private _configurationService: IConfigurationService
|
||||
) {
|
||||
super();
|
||||
this._providersMemento = new Memento('notebookProviders', this._storageService);
|
||||
@@ -581,11 +583,21 @@ export class NotebookService extends Disposable implements INotebookService {
|
||||
if (notebookUri.scheme === Schemas.untitled) {
|
||||
return true;
|
||||
}
|
||||
const trustedBooksConfigKey = 'notebook.trustedBooks';
|
||||
|
||||
let cacheInfo = this.trustedNotebooksMemento.trustedNotebooksCache[notebookUri.toString()];
|
||||
if (!cacheInfo) {
|
||||
// This notebook was never trusted
|
||||
return false;
|
||||
// Check if the notebook belongs to a book that's trusted
|
||||
// and is not part of untrusted queue.
|
||||
let trustedBookDirectories: string[] = !this._unTrustedCacheQueue.find(n => n === notebookUri) ? this._configurationService?.getValue(trustedBooksConfigKey) ?? [] : [];
|
||||
if (trustedBookDirectories.find(b => notebookUri.fsPath.indexOf(b) > -1)) {
|
||||
return true;
|
||||
// note: we're ignoring the dirty check below since that's needed only when
|
||||
// someone trusts notebook after it's loaded and this check is during the load time
|
||||
} else {
|
||||
// This notebook was never trusted
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// This was trusted. If it's not dirty (e.g. if we're not working on our cached copy)
|
||||
// then should verify it's not been modified on disk since that invalidates trust relationship
|
||||
|
||||
Reference in New Issue
Block a user