File tree 2 files changed +8
-6
lines changed
src/main/scala/sbtassembly
2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -699,21 +699,22 @@ object Assembly {
699
699
700
700
private [sbtassembly] def sha1 = MessageDigest .getInstance(" SHA-1" )
701
701
702
- private [sbtassembly] def sha1Content (b : Array [ Byte ] ): String =
703
- byteArrayInputStreamResource(b) { in =>
702
+ private [sbtassembly] def sha1Content (stream : InputStream ): String =
703
+ {
704
704
val messageDigest = sha1
705
705
val buffer = new Array [Byte ](8192 )
706
706
707
707
@ tailrec
708
708
def read (): Unit = {
709
- val byteCount = in .read(buffer)
709
+ val byteCount = stream .read(buffer)
710
710
if (byteCount >= 0 ) {
711
711
messageDigest.update(buffer, 0 , byteCount)
712
712
read()
713
713
}
714
714
}
715
715
716
716
read()
717
+ stream.close()
717
718
bytesToString(messageDigest.digest())
718
719
}
719
720
Original file line number Diff line number Diff line change @@ -122,10 +122,11 @@ object MergeStrategy {
122
122
* Verifies if all the conflicts have the same content, otherwise error out
123
123
*/
124
124
val deduplicate : MergeStrategy = MergeStrategy (" Deduplicate" ) { conflicts =>
125
- val conflictContents = conflicts.map(_.stream()).map(Streamable .bytes(_))
126
- val fingerprints = Set () ++ conflictContents.map(sbtassembly.Assembly .sha1Content)
125
+ val fingerprints = conflicts.map(dep =>
126
+ sbtassembly.Assembly .sha1Content(dep.stream())
127
+ ).toSet
127
128
if (fingerprints.size == 1 )
128
- Right (Vector (JarEntry (conflicts.head.target, () => new ByteArrayInputStream (conflictContents .head) )))
129
+ Right (Vector (JarEntry (conflicts.head.target, conflicts .head.stream )))
129
130
else
130
131
Left (
131
132
s " Deduplicate found different file contents in the following: $newLineIndented${conflicts.mkString(newLineIndented)}"
You can’t perform that action at this time.
0 commit comments