Skip to content

Commit

Permalink
fix: rls check on move (#400)
Browse files Browse the repository at this point in the history
  • Loading branch information
fenos authored Mar 28, 2024
1 parent 21e9bde commit 2af9fe9
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/storage/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,16 +341,8 @@ export class ObjectStorage {
return Promise.all([
db.findObject(this.bucketId, sourceObjectName, 'id'),
db.updateObject(this.bucketId, sourceObjectName, {
name: sourceObjectName,
version: '1',
owner,
}),
// We also check if we can create the destination object
// before starting the move
db.asSuperUser().createObject({
name: destinationObjectName,
version: newVersion,
bucket_id: this.bucketId,
owner,
}),
])
Expand All @@ -372,15 +364,15 @@ export class ObjectStorage {
const metadata = await this.backend.headObject(storageS3Bucket, s3DestinationKey, newVersion)

await this.db.asSuperUser().withTransaction(async (db) => {
await db.createObject({
await db.findObject(this.bucketId, sourceObjectName, 'id', { forUpdate: true })

await db.updateObject(this.bucketId, sourceObjectName, {
name: destinationObjectName,
version: newVersion,
bucket_id: this.bucketId,
owner: sourceObj.owner,
metadata,
})

await db.deleteObject(this.bucketId, sourceObjectName, sourceObj.version)
await ObjectAdminDelete.send({
name: sourceObjectName,
bucketId: this.bucketId,
Expand Down

0 comments on commit 2af9fe9

Please sign in to comment.