2022-03-22 23:07:14 +03:00
|
|
|
Prevent state collisions
|
|
|
|
|
|
|
|
Previously if you opened different workspaces that had the same filesystem path
|
|
|
|
(for example if you have /home/coder on two different machines that are both
|
|
|
|
accessed through the same host) they would conflict with each other. This
|
|
|
|
ensures that different browser paths will be unique (for example /workspace1 and
|
|
|
|
/workspace2).
|
|
|
|
|
|
|
|
The easiest way to test is to open files in the same workspace using both / and
|
|
|
|
/vscode and make sure they are not interacting with each other.
|
|
|
|
|
2022-08-17 04:26:19 +03:00
|
|
|
Index: code-server/lib/vscode/src/vs/workbench/services/storage/browser/storageService.ts
|
2022-03-22 23:07:14 +03:00
|
|
|
===================================================================
|
2022-08-17 04:26:19 +03:00
|
|
|
--- code-server.orig/lib/vscode/src/vs/workbench/services/storage/browser/storageService.ts
|
|
|
|
+++ code-server/lib/vscode/src/vs/workbench/services/storage/browser/storageService.ts
|
|
|
|
@@ -17,6 +17,7 @@ import { AbstractStorageService, isProfi
|
2022-10-18 02:30:39 +03:00
|
|
|
import { isUserDataProfile, IUserDataProfile } from 'vs/platform/userDataProfile/common/userDataProfile';
|
2022-03-31 02:33:58 +03:00
|
|
|
import { IAnyWorkspaceIdentifier } from 'vs/platform/workspace/common/workspace';
|
2022-08-17 04:26:19 +03:00
|
|
|
import { IUserDataProfileService } from 'vs/workbench/services/userDataProfile/common/userDataProfile';
|
2022-03-22 23:07:14 +03:00
|
|
|
+import { hash } from 'vs/base/common/hash';
|
|
|
|
|
|
|
|
export class BrowserStorageService extends AbstractStorageService {
|
|
|
|
|
2022-10-18 02:30:39 +03:00
|
|
|
@@ -297,7 +298,11 @@ export class IndexedDBStorageDatabase ex
|
2022-03-22 23:07:14 +03:00
|
|
|
}
|
|
|
|
|
2022-10-18 02:30:39 +03:00
|
|
|
static async createWorkspaceStorage(workspaceId: string, logService: ILogService): Promise<IIndexedDBStorageDatabase> {
|
|
|
|
- return IndexedDBStorageDatabase.create({ id: workspaceId }, logService);
|
|
|
|
+ // Add a unique ID based on the current path for per-workspace databases.
|
|
|
|
+ // This prevents workspaces on different machines that share the same domain
|
|
|
|
+ // and file path from colliding (since it does not appear IndexedDB can be
|
|
|
|
+ // scoped to a path) as long as they are hosted on different paths.
|
|
|
|
+ return IndexedDBStorageDatabase.create({ id: workspaceId + '-' + hash(location.pathname.toString().replace(/\/$/, "")).toString(16) }, logService);
|
|
|
|
}
|
|
|
|
|
|
|
|
static async create(options: IndexedDBStorageDatabaseOptions, logService: ILogService): Promise<IIndexedDBStorageDatabase> {
|