Skip to content

Commit 80fafd5

Browse files
author
Sharon Shabtai
authored
Merge pull request #309 from scribe/putJobFix
Put job fix
2 parents af36894 + 9598097 commit 80fafd5

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

build.gradle

+1-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ subprojects {
4646
apply plugin: "org.jlleitschuh.gradle.ktlint"
4747

4848
sourceCompatibility = JavaVersion.VERSION_1_8
49-
kotlin { experimental { coroutines 'enable' } }
5049

5150
repositories {
5251
maven {
@@ -76,7 +75,7 @@ subprojects {
7675
compile 'com.google.inject.extensions:guice-assistedinject:4.2.2'
7776
compile 'com.google.guava:guava:28.1-jre'
7877
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
79-
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.1'
78+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5'
8079
testCompile "org.hamcrest:hamcrest-all:1.3"
8180
testCompile 'junit:junit:4.12'
8281
testCompile "org.assertj:assertj-core:3.13.2"

dsb-gui/src/main/java/com/spectralogic/dsbrowser/gui/services/jobService/data/PutJobData.kt

+6-5
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ data class PutJobData(
7070
}
7171

7272
override val job: Ds3ClientHelpers.Job by lazy {
73-
val ds3Objects = items.map { pathToDs3Object(it.second) }.flatMap { it.asIterable() }
73+
val ds3Objects = items.map { pathToDs3Object(it.second) }.flatten()
7474
ds3Objects.map { pair: Pair<Ds3Object, Path> -> Pair<String, Path>(pair.first.name, pair.second) }
7575
.forEach { prefixMap.put(it.first, it.second) }
7676
if (ds3Objects.isEmpty()) {
@@ -120,16 +120,18 @@ data class PutJobData(
120120
override fun getObjectChannelBuilder(prefix: String): Ds3ClientHelpers.ObjectChannelBuilder =
121121
EmptyChannelBuilder(FileObjectPutter(prefixMap.get(prefix)!!.parent), prefixMap.get(prefix)!!)
122122

123-
private fun pathToDs3Object(path: Path): Sequence<Pair<Ds3Object, Path>> {
123+
private fun pathToDs3Object(path: Path): List<Pair<Ds3Object, Path>> {
124+
val parent = path.parent
124125
return path
125126
.toFile()
126127
.walk(FileWalkDirection.TOP_DOWN)
127128
.filter(::rejectEmptyDirectory)
128129
.filter(::rejectDeadLinks)
129130
.map(::addSize)
130-
.map(::convertToDs3Object)
131+
.map { convertToDs3Object(it, parent) }
131132
.map { Pair(it, path) }
132133
.distinct()
134+
.toList()
133135
}
134136

135137
private fun addSize(file: File): Pair<File, Long> =
@@ -138,9 +140,8 @@ data class PutJobData(
138140
private fun rejectEmptyDirectory(file: File) =
139141
!(file.isDirectory && Files.list(file.toPath()).use { f -> f.findAny().isPresent })
140142

141-
private fun convertToDs3Object(fileParts: Pair<File, Long>): Ds3Object {
143+
private fun convertToDs3Object(fileParts: Pair<File, Long>, parent: Path): Ds3Object {
142144
val (file, size) = fileParts
143-
val parent = file.toPath().parent
144145
val pathBuilder = StringBuilder(targetDir)
145146
val localDelim = file.toPath().fileSystem.separator
146147
pathBuilder.append(parent.relativize(file.toPath()).toString().replace(localDelim, "/"))

0 commit comments

Comments
 (0)