mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Merge from vscode 93309f060778f6480a7d2a13913e6e7c624e9bc7
This commit is contained in:
@@ -88,7 +88,7 @@ export class AuthenticationService extends Disposable implements IAuthentication
|
||||
this._onDidChangeSessions.fire({ providerId: id, event: event });
|
||||
const provider = this._authenticationProviders.get(id);
|
||||
if (provider) {
|
||||
provider.updateSessionItems();
|
||||
provider.updateSessionItems(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/
|
||||
import { VSBuffer } from 'vs/base/common/buffer';
|
||||
import { TextSnapshotReadable, stringToSnapshot } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
|
||||
export interface IBackupFilesModel {
|
||||
resolve(backupRoot: URI): Promise<IBackupFilesModel>;
|
||||
@@ -114,7 +115,8 @@ export class BackupFileService implements IBackupFileService {
|
||||
|
||||
constructor(
|
||||
@IWorkbenchEnvironmentService private environmentService: IWorkbenchEnvironmentService,
|
||||
@IFileService protected fileService: IFileService
|
||||
@IFileService protected fileService: IFileService,
|
||||
@ILogService private readonly logService: ILogService
|
||||
) {
|
||||
this.impl = this.initialize();
|
||||
}
|
||||
@@ -128,7 +130,7 @@ export class BackupFileService implements IBackupFileService {
|
||||
private initialize(): BackupFileServiceImpl | InMemoryBackupFileService {
|
||||
const backupWorkspaceResource = this.environmentService.configuration.backupWorkspaceResource;
|
||||
if (backupWorkspaceResource) {
|
||||
return new BackupFileServiceImpl(backupWorkspaceResource, this.hashPath, this.fileService);
|
||||
return new BackupFileServiceImpl(backupWorkspaceResource, this.hashPath, this.fileService, this.logService);
|
||||
}
|
||||
|
||||
return new InMemoryBackupFileService(this.hashPath);
|
||||
@@ -194,7 +196,8 @@ class BackupFileServiceImpl extends Disposable implements IBackupFileService {
|
||||
constructor(
|
||||
backupWorkspaceResource: URI,
|
||||
private readonly hashPath: (resource: URI) => string,
|
||||
@IFileService private readonly fileService: IFileService
|
||||
@IFileService private readonly fileService: IFileService,
|
||||
@ILogService private readonly logService: ILogService
|
||||
) {
|
||||
super();
|
||||
|
||||
@@ -372,7 +375,9 @@ class BackupFileServiceImpl extends Disposable implements IBackupFileService {
|
||||
// the meta-end marker ('\n') and as such the backup can only be invalid. We bail out
|
||||
// here if that is the case.
|
||||
if (!metaEndFound) {
|
||||
throw new Error(`Backup: Could not find meta end marker in ${backupResource}. The file is probably corrupt.`);
|
||||
this.logService.error(`Backup: Could not find meta end marker in ${backupResource}. The file is probably corrupt.`);
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return { value: factory, meta };
|
||||
|
||||
@@ -62,12 +62,13 @@ export class NodeTestBackupFileService extends BackupFileService {
|
||||
|
||||
constructor(workspaceBackupPath: string) {
|
||||
const environmentService = new TestBackupEnvironmentService(workspaceBackupPath);
|
||||
const fileService = new FileService(new NullLogService());
|
||||
const diskFileSystemProvider = new DiskFileSystemProvider(new NullLogService());
|
||||
const logService = new NullLogService();
|
||||
const fileService = new FileService(logService);
|
||||
const diskFileSystemProvider = new DiskFileSystemProvider(logService);
|
||||
fileService.registerProvider(Schemas.file, diskFileSystemProvider);
|
||||
fileService.registerProvider(Schemas.userData, new FileUserDataProvider(environmentService.appSettingsHome, environmentService.backupHome, diskFileSystemProvider, environmentService));
|
||||
|
||||
super(environmentService, fileService);
|
||||
super(environmentService, fileService, logService);
|
||||
|
||||
this.fileService = fileService;
|
||||
this.backupResourceJoiners = [];
|
||||
@@ -99,6 +100,14 @@ export class NodeTestBackupFileService extends BackupFileService {
|
||||
this.discardBackupJoiners.pop()!();
|
||||
}
|
||||
}
|
||||
|
||||
async getBackupContents(resource: URI): Promise<string> {
|
||||
const backupResource = this.toBackupResource(resource);
|
||||
|
||||
const fileContents = await this.fileService.readFile(backupResource);
|
||||
|
||||
return fileContents.value.toString();
|
||||
}
|
||||
}
|
||||
|
||||
suite('BackupFileService', () => {
|
||||
@@ -473,7 +482,7 @@ suite('BackupFileService', () => {
|
||||
await testResolveBackup(fooBarFile, contents, meta, null);
|
||||
});
|
||||
|
||||
test('should throw an error when restoring invalid backup', async () => {
|
||||
test('should ignore invalid backups', async () => {
|
||||
const contents = 'test\nand more stuff';
|
||||
|
||||
await service.backup(fooBarFile, createTextBufferFactory(contents).create(DefaultEndOfLine.LF).createSnapshot(false), 1);
|
||||
@@ -485,14 +494,14 @@ suite('BackupFileService', () => {
|
||||
|
||||
await service.fileService.writeFile(service.toBackupResource(fooBarFile), VSBuffer.fromString(''));
|
||||
|
||||
let err: Error;
|
||||
let err: Error | undefined = undefined;
|
||||
try {
|
||||
await service.resolve<IBackupTestMetaData>(fooBarFile);
|
||||
} catch (error) {
|
||||
err = error;
|
||||
}
|
||||
|
||||
assert.ok(err!);
|
||||
assert.ok(!err);
|
||||
});
|
||||
|
||||
async function testResolveBackup(resource: URI, contents: string, meta?: IBackupTestMetaData, expectedMeta?: IBackupTestMetaData | null) {
|
||||
|
||||
@@ -11,6 +11,7 @@ import { Event } from 'vs/base/common/event';
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
import { IAction, Action } from 'vs/base/common/actions';
|
||||
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
|
||||
import { IStorageKeysSyncRegistryService } from 'vs/platform/userDataSync/common/storageKeys';
|
||||
|
||||
export class NotificationService extends Disposable implements INotificationService {
|
||||
|
||||
@@ -19,7 +20,10 @@ export class NotificationService extends Disposable implements INotificationServ
|
||||
private _model: INotificationsModel = this._register(new NotificationsModel());
|
||||
get model(): INotificationsModel { return this._model; }
|
||||
|
||||
constructor(@IStorageService private readonly storageService: IStorageService) {
|
||||
constructor(
|
||||
@IStorageService private readonly storageService: IStorageService,
|
||||
@IStorageKeysSyncRegistryService private readonly storageKeysSyncRegistryService: IStorageKeysSyncRegistryService
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
@@ -64,10 +68,15 @@ export class NotificationService extends Disposable implements INotificationServ
|
||||
let handle: INotificationHandle;
|
||||
if (notification.neverShowAgain) {
|
||||
const scope = notification.neverShowAgain.scope === NeverShowAgainScope.WORKSPACE ? StorageScope.WORKSPACE : StorageScope.GLOBAL;
|
||||
const id = notification.neverShowAgain.id;
|
||||
|
||||
// opt-in to syncing if global
|
||||
if (scope === StorageScope.GLOBAL) {
|
||||
this.storageKeysSyncRegistryService.registerStorageKey({ key: id, version: 1 });
|
||||
}
|
||||
|
||||
// If the user already picked to not show the notification
|
||||
// again, we return with a no-op notification here
|
||||
const id = notification.neverShowAgain.id;
|
||||
if (this.storageService.getBoolean(id, scope)) {
|
||||
return new NoOpNotification();
|
||||
}
|
||||
@@ -115,10 +124,15 @@ export class NotificationService extends Disposable implements INotificationServ
|
||||
// Handle neverShowAgain option accordingly
|
||||
if (options?.neverShowAgain) {
|
||||
const scope = options.neverShowAgain.scope === NeverShowAgainScope.WORKSPACE ? StorageScope.WORKSPACE : StorageScope.GLOBAL;
|
||||
const id = options.neverShowAgain.id;
|
||||
|
||||
// opt-in to syncing if global
|
||||
if (scope === StorageScope.GLOBAL) {
|
||||
this.storageKeysSyncRegistryService.registerStorageKey({ key: id, version: 1 });
|
||||
}
|
||||
|
||||
// If the user already picked to not show the notification
|
||||
// again, we return with a no-op notification here
|
||||
const id = options.neverShowAgain.id;
|
||||
if (this.storageService.getBoolean(id, scope)) {
|
||||
return new NoOpNotification();
|
||||
}
|
||||
|
||||
@@ -68,7 +68,14 @@ export class ProgressService extends Disposable implements IProgressService {
|
||||
case ProgressLocation.Notification:
|
||||
return this.withNotificationProgress({ ...options, location }, task, onDidCancel);
|
||||
case ProgressLocation.Window:
|
||||
return this.withWindowProgress({ ...options, location }, task);
|
||||
if ((options as IProgressWindowOptions).command) {
|
||||
// Window progress with command get's shown in the status bar
|
||||
return this.withWindowProgress({ ...options, location }, task);
|
||||
}
|
||||
// Window progress without command can be shown as silent notification
|
||||
// which will first appear in the status bar and can then be brought to
|
||||
// the front when clicking.
|
||||
return this.withNotificationProgress({ ...options, silent: true, location: ProgressLocation.Notification }, task, onDidCancel);
|
||||
case ProgressLocation.Explorer:
|
||||
return this.withViewletProgress('workbench.view.explorer', task, { ...options, location });
|
||||
case ProgressLocation.Scm:
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
import { IWorkspacesService, IWorkspaceFolderCreationData, IWorkspaceIdentifier, IEnterWorkspaceResult, IRecentlyOpened, restoreRecentlyOpened, IRecent, isRecentFile, isRecentFolder, toStoreData, IStoredWorkspaceFolder, getStoredWorkspaceFolder, WORKSPACE_EXTENSION, IStoredWorkspace } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
|
||||
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
@@ -16,6 +16,7 @@ import { IFileService, FileOperationError, FileOperationResult } from 'vs/platfo
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
import { joinPath } from 'vs/base/common/resources';
|
||||
import { VSBuffer } from 'vs/base/common/buffer';
|
||||
import { IStorageKeysSyncRegistryService } from 'vs/platform/userDataSync/common/storageKeys';
|
||||
|
||||
export class BrowserWorkspacesService extends Disposable implements IWorkspacesService {
|
||||
|
||||
@@ -23,18 +24,22 @@ export class BrowserWorkspacesService extends Disposable implements IWorkspacesS
|
||||
|
||||
_serviceBrand: undefined;
|
||||
|
||||
private readonly _onRecentlyOpenedChange: Emitter<void> = this._register(new Emitter<void>());
|
||||
readonly onRecentlyOpenedChange: Event<void> = this._onRecentlyOpenedChange.event;
|
||||
private readonly _onRecentlyOpenedChange = this._register(new Emitter<void>());
|
||||
readonly onRecentlyOpenedChange = this._onRecentlyOpenedChange.event;
|
||||
|
||||
constructor(
|
||||
@IStorageService private readonly storageService: IStorageService,
|
||||
@IWorkspaceContextService private readonly workspaceService: IWorkspaceContextService,
|
||||
@ILogService private readonly logService: ILogService,
|
||||
@IFileService private readonly fileService: IFileService,
|
||||
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService
|
||||
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
|
||||
@IStorageKeysSyncRegistryService storageKeysSyncRegistryService: IStorageKeysSyncRegistryService
|
||||
) {
|
||||
super();
|
||||
|
||||
// opt-in to syncing
|
||||
storageKeysSyncRegistryService.registerStorageKey({ key: BrowserWorkspacesService.RECENTLY_OPENED_KEY, version: 1 });
|
||||
|
||||
// Opening a workspace should push it as most
|
||||
// recently used to the workspaces history
|
||||
this.addWorkspaceToRecentlyOpened();
|
||||
|
||||
Reference in New Issue
Block a user