Skip to content

Commit 3b3235a

Browse files
committed
refactor: remove database migration patch & test
Drop migration code since it's been 6 months since 4.0.2 and we no longer need this. See: #5482 (comment)
1 parent 101d4ee commit 3b3235a

File tree

2 files changed

+0
-108
lines changed

2 files changed

+0
-108
lines changed

patches/unique-db.diff

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ ensures that different browser paths will be unique (for example /workspace1 and
99
The easiest way to test is to open files in the same workspace using both / and
1010
/vscode and make sure they are not interacting with each other.
1111

12-
It should also migrate old databases which can be tested by opening in an old
13-
code-server.
14-
15-
This has e2e tests.
16-
1712
Index: code-server/lib/vscode/src/vs/workbench/services/storage/browser/storageService.ts
1813
===================================================================
1914
--- code-server.orig/lib/vscode/src/vs/workbench/services/storage/browser/storageService.ts
@@ -39,29 +34,3 @@ Index: code-server/lib/vscode/src/vs/workbench/services/storage/browser/storageS
3934
}
4035
}
4136

42-
@@ -141,6 +146,25 @@ export class BrowserStorageService exten
43-
44-
await this.workspaceStorage.init();
45-
46-
+ const firstWorkspaceOpen = this.workspaceStorage.getBoolean(IS_NEW_KEY);
47-
+ if (firstWorkspaceOpen === undefined) {
48-
+ // Migrate the old database.
49-
+ let db: IIndexedDBStorageDatabase | undefined
50-
+ try {
51-
+ db = await IndexedDBStorageDatabase.create({ id: this.payload.id }, this.logService)
52-
+ const items = await db.getItems()
53-
+ for (const [key, value] of items) {
54-
+ this.workspaceStorage.set(key, value);
55-
+ }
56-
+ } catch (error) {
57-
+ this.logService.error(`[IndexedDB Storage ${this.payload.id}] migrate error: ${toErrorMessage(error)}`);
58-
+ } finally {
59-
+ if (db) {
60-
+ db.close()
61-
+ }
62-
+ }
63-
+ }
64-
+
65-
this.updateIsNew(this.workspaceStorage);
66-
}
67-

test/e2e/codeServer.test.ts

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
import * as cp from "child_process"
21
import { promises as fs } from "fs"
3-
import * as os from "os"
42
import * as path from "path"
5-
import * as util from "util"
63
import { getMaybeProxiedCodeServer } from "../utils/helpers"
74
import { describe, test, expect } from "./baseFixture"
85
import { CodeServer } from "./models/CodeServer"
@@ -17,30 +14,6 @@ describe("code-server", [], {}, () => {
1714
await Promise.all(procs.map((cs) => cs.close()))
1815
})
1916

20-
/**
21-
* Spawn a specific version of code-server using the install script.
22-
*/
23-
const spawn = async (version: string, dir?: string): Promise<CodeServer> => {
24-
let instance = instances.get(version)
25-
if (!instance) {
26-
await util.promisify(cp.exec)(`./install.sh --method standalone --version ${version}`, {
27-
cwd: path.join(__dirname, "../.."),
28-
})
29-
30-
instance = new CodeServer(
31-
"code-server@" + version,
32-
["--auth=none"],
33-
{ VSCODE_DEV: "" },
34-
dir,
35-
`${os.homedir()}/.local/lib/code-server-${version}`,
36-
)
37-
38-
instances.set(version, instance)
39-
}
40-
41-
return instance
42-
}
43-
4417
test("should navigate to home page", async ({ codeServerPage }) => {
4518
// We navigate codeServer before each test
4619
// and we start the test with a storage state
@@ -68,54 +41,4 @@ describe("code-server", [], {}, () => {
6841
await fs.writeFile(file, "bar")
6942
await codeServerPage.openFile(file)
7043
})
71-
72-
test("should migrate state to avoid collisions", async ({ codeServerPage }) => {
73-
// This can take a very long time in development because of how long pages
74-
// take to load and we are doing a lot of that here.
75-
if (process.env.VSCODE_DEV === "1") {
76-
test.slow()
77-
}
78-
79-
const dir = await codeServerPage.workspaceDir
80-
const files = [path.join(dir, "foo"), path.join(dir, "bar")]
81-
await Promise.all(
82-
files.map((file) => {
83-
return fs.writeFile(file, path.basename(file))
84-
}),
85-
)
86-
87-
// Open a file in the latest instance.
88-
await codeServerPage.openFile(files[0])
89-
await codeServerPage.stateFlush()
90-
91-
// Open a file in an older version of code-server. It should not see the
92-
// file opened in the new instance since the database has a different
93-
// name. This must be accessed through the proxy so it shares the same
94-
// domain and can write to the same database.
95-
const cs = await spawn("4.0.2", dir)
96-
const address = new URL(await cs.address())
97-
98-
await codeServerPage.navigate("/proxy/" + address.port + "/")
99-
await codeServerPage.openFile(files[1])
100-
expect(await codeServerPage.tabIsVisible(files[0])).toBe(false)
101-
await codeServerPage.stateFlush()
102-
103-
// Move back to latest code-server. We should see the file we previously
104-
// opened with it but not the old code-server file because the new instance
105-
// already created its own database on this path and will avoid migrating.
106-
await codeServerPage.navigate()
107-
await codeServerPage.waitForTab(files[0])
108-
expect(await codeServerPage.tabIsVisible(files[1])).toBe(false)
109-
110-
// Open a new path in latest code-server. This one should migrate the
111-
// database from old code-server but see nothing from the new database
112-
// created on the root.
113-
await codeServerPage.navigate("/vscode")
114-
await codeServerPage.waitForTab(files[1])
115-
expect(await codeServerPage.tabIsVisible(files[0])).toBe(false)
116-
// Should still be open after a reload.
117-
await codeServerPage.navigate("/vscode")
118-
await codeServerPage.waitForTab(files[1])
119-
expect(await codeServerPage.tabIsVisible(files[0])).toBe(false)
120-
})
12144
})

0 commit comments

Comments
 (0)