diff --git a/common/spaces/datastore_space_primitives.ts b/common/spaces/datastore_space_primitives.ts index 3880085..a5ecf74 100644 --- a/common/spaces/datastore_space_primitives.ts +++ b/common/spaces/datastore_space_primitives.ts @@ -20,7 +20,7 @@ export class DataStoreSpacePrimitives implements SpacePrimitives { async fetchFileList(): Promise { return (await this.ds.query({ 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; } }