Skip to content

Commit 506fe35

Browse files
authored
verify existent storage path in createBinary. (#3610)
1 parent 040e16b commit 506fe35

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

roda-core/roda-core/src/main/java/org/roda/core/storage/DefaultTransactionalStorageService.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,11 @@ public Binary createBinary(StoragePath storagePath, ContentPayload payload, bool
290290
NotFoundException {
291291
TransactionalStoragePathOperationLog operationLog;
292292
// if storage path is agent we need to register a create or update operation
293+
294+
if (mainStorageService.exists(storagePath)) {
295+
throw new AlreadyExistsException("Binary already exists: " + storagePath);
296+
}
297+
293298
if (storagePath.getDirectoryPath() != null && !storagePath.getDirectoryPath().isEmpty()
294299
&& storagePath.getDirectoryPath().getFirst().equals(RodaConstants.STORAGE_DIRECTORY_AGENTS)) {
295300
operationLog = registerOperation(storagePath, OperationType.CREATE_OR_UPDATE);

0 commit comments

Comments
 (0)