Skip to content

Commit 86c5b1c

Browse files
committed
Ensure S3 storage service only cleans files marked deleted
There was a bug in the initial implementation of the S3 object storage service in 65c5f29: "Move private storage to S3-backed implementation" which allows `cleanFile()` to clean files which aren't marked as deleted. This isn't a significant issue since we don't currently rely on it only functioning on files marked deleted, but the latter behavior is in the API documentation, consistent with how the sister function `cleanAllFiles()` behaves, and helpful for preventing accidental file deletions, so we should fix it.
1 parent ceacbe9 commit 86c5b1c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

console/src/main/kotlin/app/accrescent/parcelo/console/storage/S3ObjectStorageService.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ class S3ObjectStorageService(
9494
}
9595

9696
override suspend fun cleanObject(id: Int) {
97-
val file = transaction { File.findById(id) } ?: return
97+
val file = transaction {
98+
File.find { Files.id eq id and (deleted eq true) }.singleOrNull()
99+
} ?: return
98100
val s3ObjectKey = file.s3ObjectKey
99101

100102
S3Client {

0 commit comments

Comments
 (0)