Skip to content

Commit

Permalink
Rebuild artifacts when necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
propensive committed Mar 20, 2024
1 parent cd9caf9 commit 7a25554
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion res/build.id
Original file line number Diff line number Diff line change
@@ -1 +1 @@
887
891
22 changes: 15 additions & 7 deletions src/engine/build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,14 @@ class Builder():
val binaries: List[Hash] = Nil

def run(hash: Hash)
(using FrontEnd, Log[Display], DaemonService[?], Installation, Monitor, SystemProperties, Environment, Internet)
(using FrontEnd,
Log[Display],
DaemonService[?],
Installation,
Monitor,
SystemProperties,
Environment,
Internet)
: PhaseResult =

attempt[AggregateError[BuildError]]:
Expand All @@ -201,14 +208,15 @@ class Builder():
given (BuildError fixes CancelError) = error => BuildError()

val inputs = antecedents.map(task(_))

val checksumPath = output / p"checksum"

def checksumsDiffer(): Boolean =
val currentHash = destination.as[File].stream[Bytes].digest[Sha2[256]].bytes.encodeAs[Base32]
checksumPath.as[File].readAs[Text] != currentHash

def savedChecksum = if checksumPath.exists() then checksumPath.as[File].readAs[Text] else Unset

def fileChecksum = if !destination.exists() then Unset else
destination.as[File].stream[Bytes].digest[Sha2[256]].bytes.encodeAs[Base32]

if !destination.exists() || checksumPath.exists() && checksumsDiffer() then
if savedChecksum.absent || fileChecksum.absent || savedChecksum != fileChecksum || counterPath.present
then
val tmpPath = unsafely(installation.work / PathName(Uuid().show))

val zipFile = basis.lay(ZipFile.create(tmpPath)): basis =>
Expand Down

0 comments on commit 7a25554

Please sign in to comment.