Skip to content

Commit

Permalink
use DB_BUILD env var
Browse files Browse the repository at this point in the history
ref #120
  • Loading branch information
Foxcapades committed Nov 29, 2022
1 parent 2c6634c commit d799847
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
11 changes: 11 additions & 0 deletions rest-service/src/main/kotlin/mb/lib/config/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,15 @@ object Config : Options() {
var maxAASeqSize = 102_400
private set

// ╠════════════════════════════════════════════════════════════════════════════════════════╣ //

@Option(
names = ["--db-build"],
arity = "1",
defaultValue = "\${env:DB_BUILD}",
description = ["Site DB build number"],
required = true,
)
var dbBuild = 60
private set
}
18 changes: 9 additions & 9 deletions rest-service/src/main/kotlin/mb/lib/path/index.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
package mb.lib.path

import mb.lib.config.Config
import java.io.File
import java.util.*
import java.util.stream.Stream
import kotlin.io.path.Path

fun findDBPath(site: String, organism: String, target: String): Optional<String> {
val root = Config.dbMountPath
Expand All @@ -24,14 +24,14 @@ fun findDBPath(site: String, organism: String, target: String): Optional<String>
* @return An array of zero or more builds available for the given [site]. If
* the site is invalid, or no builds exist, an empty array will be returned.
*/
fun findBuildVersionsFor(site: String): Stream<String> = File(Config.dbMountPath, site)
.takeIf(File::isDirectory)
?.listFiles(File::isDirectory)
?.let(Arrays::stream)
?.map(File::getName)
?.sorted(Comparator.reverseOrder())
?:
Stream.empty()
fun findBuildVersionsFor(site: String): Stream<String> =
Path(Config.dbMountPath, site, "build-${Config.dbBuild}").toFile()
.let {
if (it.exists())
Stream.of(it.name)
else
Stream.empty()
}

/**
* Attempts to locate the correct, possibly new Blast target DB path.
Expand Down

0 comments on commit d799847

Please sign in to comment.