fix(electron): export and import (#9767)

This commit is contained in:
forehalo
2025-01-20 08:48:03 +00:00
parent 2e18ae59e3
commit cb53baca89
26 changed files with 332 additions and 453 deletions

View File

@@ -41,12 +41,6 @@ export class SqliteV1BlobStorage extends BlobStorageBase {
};
}
override async delete(key: string, permanently: boolean) {
if (permanently) {
await this.db.deleteBlob(this.options.type, this.options.id, key);
}
}
override async list() {
const keys = await this.db.getBlobKeys(this.options.type, this.options.id);
@@ -57,6 +51,9 @@ export class SqliteV1BlobStorage extends BlobStorageBase {
createdAt: new Date(),
}));
}
override async delete() {
// no more deletes
}
override async set() {
// no more writes

View File

@@ -6,17 +6,16 @@ interface NativeDBV1Apis {
workspaceId: string,
key: string
) => Promise<Buffer | null>;
deleteBlob: (
spaceType: SpaceType,
workspaceId: string,
key: string
) => Promise<void>;
getBlobKeys: (spaceType: SpaceType, workspaceId: string) => Promise<string[]>;
getDocAsUpdates: (
spaceType: SpaceType,
workspaceId: string,
subdocId: string
) => Promise<Uint8Array>;
getDocTimestamps: (
spaceType: SpaceType,
workspaceId: string
) => Promise<{ docId?: string; timestamp: Date }[]>;
}
export let apis: NativeDBV1Apis | null = null;

View File

@@ -56,6 +56,27 @@ export class SqliteV1DocStorage extends DocStorageBase<{
};
}
override async getDocTimestamps() {
const timestamps = await this.db.getDocTimestamps(
this.options.type,
this.options.id
);
if (!timestamps) {
return {};
}
const idConverter = await this.getIdConverter();
return timestamps.reduce(
(ret, { docId, timestamp }) => {
ret[idConverter.oldIdToNewId(docId ?? this.options.id)] = timestamp;
return ret;
},
{} as Record<string, Date>
);
}
override async deleteDoc() {
return;
}
@@ -64,10 +85,6 @@ export class SqliteV1DocStorage extends DocStorageBase<{
return null;
}
override async getDocTimestamps() {
return {};
}
override async getDocTimestamp() {
return null;
}