33 * Licensed under the MIT License. See License.txt in the project root for license information.
44 *--------------------------------------------------------------------------------------------*/
55
6- import { IStorage , StorageService } from 'vs/platform/storage/common/storageService ' ;
6+ import { StorageLegacyService , IStorageLegacy } from 'vs/platform/storage/common/storageLegacyService ' ;
77import { endsWith , startsWith , rtrim } from 'vs/base/common/strings' ;
88import { URI } from 'vs/base/common/uri' ;
99import { IWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces' ;
@@ -29,8 +29,8 @@ import { IWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
2929 * => no longer being used (used for empty workspaces previously)
3030 */
3131
32- const EMPTY_WORKSPACE_PREFIX = `${ StorageService . COMMON_PREFIX } workspace/empty:` ;
33- const MULTI_ROOT_WORKSPACE_PREFIX = `${ StorageService . COMMON_PREFIX } workspace/root:` ;
32+ const EMPTY_WORKSPACE_PREFIX = `${ StorageLegacyService . COMMON_PREFIX } workspace/empty:` ;
33+ const MULTI_ROOT_WORKSPACE_PREFIX = `${ StorageLegacyService . COMMON_PREFIX } workspace/root:` ;
3434
3535export type StorageObject = { [ key : string ] : string } ;
3636
@@ -44,7 +44,7 @@ export interface IParsedStorage {
4444/**
4545 * Parses the local storage implementation into global, multi root, folder and empty storage.
4646 */
47- export function parseStorage ( storage : IStorage ) : IParsedStorage {
47+ export function parseStorage ( storage : IStorageLegacy ) : IParsedStorage {
4848 const globalStorage = new Map < string , string > ( ) ;
4949 const folderWorkspacesStorage = new Map < string /* workspace file resource */ , StorageObject > ( ) ;
5050 const emptyWorkspacesStorage = new Map < string /* empty workspace id */ , StorageObject > ( ) ;
@@ -55,14 +55,14 @@ export function parseStorage(storage: IStorage): IParsedStorage {
5555 const key = storage . key ( i ) ;
5656
5757 // Workspace Storage (storage://workspace/)
58- if ( startsWith ( key , StorageService . WORKSPACE_PREFIX ) ) {
58+ if ( startsWith ( key , StorageLegacyService . WORKSPACE_PREFIX ) ) {
5959
6060 // We are looking for key: storage://workspace/<folder>/workspaceIdentifier to be able to find all folder
6161 // paths that are known to the storage. is the only way how to parse all folder paths known in storage.
62- if ( endsWith ( key , StorageService . WORKSPACE_IDENTIFIER ) ) {
62+ if ( endsWith ( key , StorageLegacyService . WORKSPACE_IDENTIFIER ) ) {
6363
6464 // storage://workspace/<folder>/workspaceIdentifier => <folder>/
65- let workspace = key . substring ( StorageService . WORKSPACE_PREFIX . length , key . length - StorageService . WORKSPACE_IDENTIFIER . length ) ;
65+ let workspace = key . substring ( StorageLegacyService . WORKSPACE_PREFIX . length , key . length - StorageLegacyService . WORKSPACE_IDENTIFIER . length ) ;
6666
6767 // macOS/Unix: Users/name/folder/
6868 // Windows: c%3A/Users/name/folder/
@@ -76,7 +76,7 @@ export function parseStorage(storage: IStorage): IParsedStorage {
7676 }
7777
7878 // storage://workspace/<folder>/workspaceIdentifier => storage://workspace/<folder>/
79- const prefix = key . substr ( 0 , key . length - StorageService . WORKSPACE_IDENTIFIER . length ) ;
79+ const prefix = key . substr ( 0 , key . length - StorageLegacyService . WORKSPACE_IDENTIFIER . length ) ;
8080 workspaces . push ( { prefix, resource : workspace } ) ;
8181 }
8282
@@ -120,11 +120,11 @@ export function parseStorage(storage: IStorage): IParsedStorage {
120120 }
121121
122122 // Global Storage (storage://global)
123- else if ( startsWith ( key , StorageService . GLOBAL_PREFIX ) ) {
123+ else if ( startsWith ( key , StorageLegacyService . GLOBAL_PREFIX ) ) {
124124
125125 // storage://global/someKey => someKey
126- const globalStorageKey = key . substr ( StorageService . GLOBAL_PREFIX . length ) ;
127- if ( startsWith ( globalStorageKey , StorageService . COMMON_PREFIX ) ) {
126+ const globalStorageKey = key . substr ( StorageLegacyService . GLOBAL_PREFIX . length ) ;
127+ if ( startsWith ( globalStorageKey , StorageLegacyService . COMMON_PREFIX ) ) {
128128 continue ; // filter out faulty keys that have the form storage://something/storage://
129129 }
130130
@@ -168,7 +168,7 @@ export function parseStorage(storage: IStorage): IParsedStorage {
168168 } ;
169169}
170170
171- export function migrateStorageToMultiRootWorkspace ( fromWorkspaceId : string , toWorkspace : IWorkspaceIdentifier , storage : IStorage ) : string {
171+ export function migrateStorageToMultiRootWorkspace ( fromWorkspaceId : string , toWorkspace : IWorkspaceIdentifier , storage : IStorageLegacy ) : string {
172172 const parsed = parseStorage ( storage ) ;
173173
174174 const newWorkspaceId = URI . from ( { path : toWorkspace . id , scheme : 'root' } ) . toString ( ) ;
@@ -186,11 +186,11 @@ export function migrateStorageToMultiRootWorkspace(fromWorkspaceId: string, toWo
186186 // Migrate existing storage to new workspace id
187187 if ( storageForWorkspace ) {
188188 Object . keys ( storageForWorkspace ) . forEach ( key => {
189- if ( key === StorageService . WORKSPACE_IDENTIFIER ) {
189+ if ( key === StorageLegacyService . WORKSPACE_IDENTIFIER ) {
190190 return ; // make sure to never migrate the workspace identifier
191191 }
192192
193- storage . setItem ( `${ StorageService . WORKSPACE_PREFIX } ${ newWorkspaceId } /${ key } ` , storageForWorkspace [ key ] ) ;
193+ storage . setItem ( `${ StorageLegacyService . WORKSPACE_PREFIX } ${ newWorkspaceId } /${ key } ` , storageForWorkspace [ key ] ) ;
194194 } ) ;
195195 }
196196
0 commit comments