File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed
model-server/src/main/kotlin/org/modelix/model/server/handlers Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -170,11 +170,11 @@ class ModelReplicationServer(val repositoriesManager: RepositoriesManager) {
170
170
fun PipelineContext <Unit , ApplicationCall >.repositoryId () = call.repositoryId()
171
171
172
172
val repositoryId = repositoryId()
173
- if (! repositoriesManager.repositoryExists(repositoryId)) {
174
- call.respond(HttpStatusCode .NotFound )
175
- } else {
176
- repositoriesManager.removeRepository(repositoryId)
173
+ val foundAndDeleted = repositoriesManager.removeRepository(repositoryId)
174
+ if (foundAndDeleted) {
177
175
call.respond(HttpStatusCode .NoContent )
176
+ } else {
177
+ call.respond(HttpStatusCode .NotFound )
178
178
}
179
179
}
180
180
Original file line number Diff line number Diff line change @@ -145,15 +145,21 @@ class RepositoriesManager(val client: LocalModelClient) {
145
145
}
146
146
}
147
147
148
- fun removeRepository (repository : RepositoryId ) {
149
- store.runTransaction {
148
+ fun removeRepository (repository : RepositoryId ): Boolean {
149
+ return store.runTransaction {
150
+ if (! repositoryExists(repository)) {
151
+ return @runTransaction false
152
+ }
153
+
150
154
for (branchName in getBranchNames(repository)) {
151
155
putVersionHash(repository.getBranchReference(branchName), null )
152
156
}
153
157
store.put(branchListKey(repository), null )
154
158
val existingRepositories = getRepositories()
155
159
val remainingRepositories = existingRepositories - repository
156
160
store.put(REPOSITORIES_LIST_KEY , remainingRepositories.joinToString(" \n " ) { it.id })
161
+
162
+ true
157
163
}
158
164
}
159
165
You can’t perform that action at this time.
0 commit comments