Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Make sure to check that the blob exists before updating or deleting it.
Fixes #99.
  • Loading branch information
tburch committed Jul 7, 2022
commit 9e1f38876ccd33ac60794066405cf237cb343e8d
4 changes: 2 additions & 2 deletions src/main/kotlin/jsonblob/api/http/ApiController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class ApiController(
return false
}

private fun delete(blobId: String) = jsonBlobStore.remove(blobId)
private fun delete(blobId: String) = jsonBlobStore.exists(blobId) && jsonBlobStore.remove(blobId)

private fun updateFirstBlobFromPath(path: String, json: String): JsonBlob? {
val ids = blobIdsFromPath(path)
Expand All @@ -170,7 +170,7 @@ class ApiController(

private fun update(blobId: String, json: String): JsonBlob? {
val resolver = idResolvers.firstOrNull { it.handles(blobId) }
return if (resolver != null) {
return if (resolver != null && jsonBlobStore.exists(blobId)) {
val created = resolver.resolveTimestamp(blobId)
val jsonBlob = JsonBlob(
id = blobId,
Expand Down