Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(desktop): saving keeps a connection catalog this build cannot read #34944

Mergedjuliusmarmingemerged 3 commits intomain fromrefs/pull/34944/headmerged by maria-rcks View on GitHub

Showing 2 changed files with 120 additions and 15 deletions.

x
0 of 2 viewed, 2 left
62 additions and 0 deletionsapps/desktop/src/app/DesktopConnectionCatalogStore.test.tsModified
View file
@@ -300,4 +300,66 @@
assert.deepStrictEqual(yield* store.get, Option.some('{"schemaVersion":1,"targets":[]}'));
}).pipe(Effect.provide(NodeServices.layer)),
+​
+ const emptyCatalog =
+ '{"schemaVersion":1,"targets":[],"profiles":[],"credentials":[],"remoteDpopTokens":[],"disabledEnvironmentIds":[]}';
+ const savedFilesHolding = Effect.fn(function* (stateDir: string, contents: string) {
+ const fileSystem = yield* FileSystem.FileSystem;
+ const path = yield* Path.Path;
+ const kept: string[] = [];
+ for (const name of yield* fileSystem.readDirectory(stateDir)) {
+ const file = path.join(stateDir, name);
+ if ((yield* fileSystem.stat(file)).type !== "File") continue;
+ if ((yield* fileSystem.readFileString(file)) === contents) kept.push(name);
+ }
+ return kept;
+ });
+​
+ it.effect("keeps a catalog this build cannot decode when the next save replaces it", () =>
+ withStore(
+ Effect.gen(function* () {
+ const path = yield* Path.Path;
+ const environment = yield* DesktopEnvironment.DesktopEnvironment;
+ const fileSystem = yield* FileSystem.FileSystem;
+ const store = yield* DesktopConnectionCatalogStore.DesktopConnectionCatalogStore;
+ const catalogPath = path.join(environment.stateDir, "connection-catalog.json");
+ assert.isTrue(
+ yield* store.set(
+ '{"schemaVersion":1,"targets":[{"_tag":"FutureConnectionTarget","environmentId":"remote"}],"profiles":[],"credentials":[],"remoteDpopTokens":[],"disabledEnvironmentIds":[]}',