Don't hash the dev bundle zip twice (#223)

This commit is contained in:
Jason Penilla 2023-11-20 14:45:30 -07:00 committed by GitHub
parent 1d88d33cc5
commit 7d2ae18db3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 3 deletions

View file

@ -299,6 +299,7 @@ abstract class PaperweightUser : Plugin<Project> {
parameters {
cache.set(cacheDir)
bundleZip.set(devBundleZip)
bundleZipHash.set(bundleHash)
downloadService.set(target.download)
genSources.set(target.genSources)
}

View file

@ -46,10 +46,10 @@ data class ExtractedBundle<C>(
fun extractDevBundle(
destinationDirectory: Path,
devBundle: Path
devBundle: Path,
newDevBundleHash: String
): ExtractedBundle<Any> {
val hashFile = destinationDirectory.resolve("current.sha256")
val newDevBundleHash = devBundle.sha256asHex()
if (destinationDirectory.exists()) {
val currentDevBundleHash = if (hashFile.isRegularFile()) hashFile.readText(Charsets.UTF_8) else ""

View file

@ -47,6 +47,7 @@ abstract class UserdevSetup : BuildService<UserdevSetup.Parameters>, SetupHandle
interface Parameters : BuildServiceParameters {
val bundleZip: RegularFileProperty
val bundleZipHash: Property<String>
val cache: RegularFileProperty
val downloadService: Property<DownloadService>
val genSources: Property<Boolean>
@ -55,7 +56,8 @@ abstract class UserdevSetup : BuildService<UserdevSetup.Parameters>, SetupHandle
private val extractDevBundle: ExtractedBundle<Any> = lockSetup(parameters.cache.path) {
val extract = extractDevBundle(
parameters.cache.path.resolve(paperSetupOutput("extractDevBundle", "dir")),
parameters.bundleZip.path
parameters.bundleZip.path,
parameters.bundleZipHash.get()
)
lastUsedFile(parameters.cache.path).writeText(System.currentTimeMillis().toString())
extract