1
0

Backwards compatibility fix for synced spaces and 'created' timestamp

This commit is contained in:
Zef Hemel 2023-11-03 09:48:07 +01:00
parent 509683c537
commit 28b0e9f9e9

View File

@ -20,7 +20,7 @@ export class DataStoreSpacePrimitives implements SpacePrimitives {
async fetchFileList(): Promise<FileMeta[]> {
return (await this.ds.query<FileMeta>({ prefix: filesMetaPrefix }))
.map((kv) => kv.value);
.map((kv) => this.ensureFileMeta(kv.value));
}
async readFile(
@ -36,7 +36,7 @@ export class DataStoreSpacePrimitives implements SpacePrimitives {
return {
data: fileContent.data,
meta: fileContent.meta,
meta: this.ensureFileMeta(fileContent.meta),
};
}
@ -86,6 +86,13 @@ export class DataStoreSpacePrimitives implements SpacePrimitives {
if (!fileMeta) {
throw new Error("Not found");
}
return this.ensureFileMeta(fileMeta);
}
ensureFileMeta(fileMeta: FileMeta): FileMeta {
if (!fileMeta.created) {
fileMeta.created = fileMeta.lastModified;
}
return fileMeta;
}
}