aboutsummaryrefslogtreecommitdiff
path: root/src/db
diff options
context:
space:
mode:
Diffstat (limited to 'src/db')
-rw-r--r--src/db/model/File.ts7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/db/model/File.ts b/src/db/model/File.ts
index 6b71f3d..89415b7 100644
--- a/src/db/model/File.ts
+++ b/src/db/model/File.ts
@@ -116,7 +116,8 @@ export default class File extends Model<File> {
}
public get metadata(): Metadata {
- return JSON.parse(this.metadataInternal) || INITIAL_METADATA;
+ return !!(this.metadataInternal) ? JSON.parse(this.metadataInternal)
+ : INITIAL_METADATA;
}
public set metadata(md: Metadata) {
@@ -128,6 +129,10 @@ export default class File extends Model<File> {
if (newMD.version !== oldMD.version + 1) {
throw new RequestError(400, 'invalid_request');
}
+ this.metadataInternal = JSON.stringify(newMD);
+ }
+ public setMetadataInternal(md: Metadata): void {
+ this.metadataInternal = JSON.stringify(md);
}
public set mimetype(mime: string) {