mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-13 11:50:56 +00:00
Fix backup hashing (#3939)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
parent
a2c861d0c4
commit
429574ce1d
@ -594,10 +594,10 @@ abstract class MongoAdapterBase implements DbAdapter {
|
||||
return undefined
|
||||
}
|
||||
let digest = (d as any)['%hash%']
|
||||
if ('%hash%' in d) {
|
||||
delete d['%hash%']
|
||||
}
|
||||
if (digest == null) {
|
||||
if ('%hash%' in d) {
|
||||
delete d['%hash%']
|
||||
}
|
||||
const doc = JSON.stringify(d)
|
||||
const hash = createHash('sha256')
|
||||
hash.update(doc)
|
||||
@ -646,10 +646,12 @@ abstract class MongoAdapterBase implements DbAdapter {
|
||||
|
||||
async load (domain: Domain, docs: Ref<Doc>[]): Promise<Doc[]> {
|
||||
return this.stripHash(
|
||||
await this.db
|
||||
.collection(domain)
|
||||
.find<Doc>({ _id: { $in: docs } })
|
||||
.toArray()
|
||||
this.stripHash(
|
||||
await this.db
|
||||
.collection(domain)
|
||||
.find<Doc>({ _id: { $in: docs } })
|
||||
.toArray()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@ -664,7 +666,7 @@ abstract class MongoAdapterBase implements DbAdapter {
|
||||
part.map((it) => ({
|
||||
replaceOne: {
|
||||
filter: { _id: it._id },
|
||||
replacement: it,
|
||||
replacement: { ...it, '%hash%': '' },
|
||||
upsert: true
|
||||
}
|
||||
}))
|
||||
@ -696,7 +698,7 @@ abstract class MongoAdapterBase implements DbAdapter {
|
||||
updateOne: {
|
||||
filter: { _id: it[0] },
|
||||
update: {
|
||||
$set: set,
|
||||
$set: { ...set, '%hash%': '' },
|
||||
...($unset !== undefined ? { $unset } : {})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user