Skip to content

Commit 9322fb4

Browse files
committed
fix(DirectoryProvenance): Dummy hash and storageKey
Should never be called, since we avoid it everywhere, so adding an empty `hash` and `storageKey` should be fine for now. Signed-off-by: Jens Keim <[email protected]>
1 parent d8514ba commit 9322fb4

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

model/src/main/kotlin/utils/FileProvenanceFileStorage.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import java.io.InputStream
2424
import org.apache.logging.log4j.kotlin.logger
2525

2626
import org.ossreviewtoolkit.model.ArtifactProvenance
27+
import org.ossreviewtoolkit.model.DirectoryProvenance
2728
import org.ossreviewtoolkit.model.HashAlgorithm
2829
import org.ossreviewtoolkit.model.KnownProvenance
2930
import org.ossreviewtoolkit.model.RepositoryProvenance
@@ -81,6 +82,7 @@ private fun KnownProvenance.hash(): String {
8182
val key = when (this) {
8283
is ArtifactProvenance -> "${sourceArtifact.url}${sourceArtifact.hash.value}"
8384
is RepositoryProvenance -> "${vcsInfo.type}${vcsInfo.url}$resolvedRevision"
85+
is DirectoryProvenance -> ""
8486
}
8587

8688
return HashAlgorithm.SHA1.calculate(key.toByteArray())

model/src/main/kotlin/utils/PostgresProvenanceFileStorage.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import org.jetbrains.exposed.sql.insert
3636
import org.jetbrains.exposed.sql.selectAll
3737

3838
import org.ossreviewtoolkit.model.ArtifactProvenance
39+
import org.ossreviewtoolkit.model.DirectoryProvenance
3940
import org.ossreviewtoolkit.model.KnownProvenance
4041
import org.ossreviewtoolkit.model.RepositoryProvenance
4142
import org.ossreviewtoolkit.model.utils.DatabaseUtils.checkDatabaseEncoding
@@ -121,4 +122,5 @@ private fun KnownProvenance.storageKey(): String =
121122
is ArtifactProvenance -> "source-artifact|${sourceArtifact.url}|${sourceArtifact.hash}"
122123
// The trailing "|" is kept for backward compatibility because there used to be an additional parameter.
123124
is RepositoryProvenance -> "vcs|${vcsInfo.type}|${vcsInfo.url}|$resolvedRevision|"
125+
is DirectoryProvenance -> ""
124126
}

0 commit comments

Comments
 (0)