Skip to content

Commit

Permalink
Set dirzip to 2010 timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
eed3si9n committed Aug 21, 2024
1 parent d134c52 commit d6a65d7
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions util-cache/src/main/scala/sbt/util/ActionCache.scala
Original file line number Diff line number Diff line change
Expand Up @@ -107,21 +107,26 @@ object ActionCache:
val json = Parser.parseFromFile(manifest.toFile()).get
Converter.fromJsonUnsafe[Manifest](json)

private val default2010Timestamp: Long = 1262304000000L

def packageDirectory(
dir: VirtualFileRef,
conv: FileConverter,
outputDirectory: Path,
): VirtualFile =
import sbt.internal.util.codec.ManifestCodec.given
val dirPath = conv.toPath(dir)
val allPaths = FileTreeView.default.list(dirPath.toGlob / ** / "*")
val allPaths = FileTreeView.default
.list(dirPath.toGlob / ** / "*")
.filter(!_._2.isDirectory)
.map(_._1)
.sortBy(_.toString())
// create a manifest of files and their hashes here
def makeManifest(manifestFile: Path): Unit =
val vfs = (allPaths.flatMap {
case (p, attr) if !attr.isDirectory =>
Some(conv.toVirtualFile(p): HashedVirtualFileRef)
case _ => None
}).toVector
val vfs = (allPaths
.map: p =>
(conv.toVirtualFile(p): HashedVirtualFileRef))
.toVector
val manifest = Manifest(
version = "0.1.0",
outputFiles = vfs,
Expand All @@ -138,7 +143,7 @@ object ActionCache:
case p if p == dirPath => Nil
case p if p == mPath => (mPath.toFile() -> manifestFileName) :: Nil
case f => (f.toFile() -> outputDirectory.relativize(f).toString) :: Nil
IO.zip((allPaths.map(_._1) ++ Seq(mPath)).flatMap(rebase), zipPath.toFile(), None)
IO.zip((allPaths ++ Seq(mPath)).flatMap(rebase), zipPath.toFile(), Some(default2010Timestamp))
conv.toVirtualFile(zipPath)

/**
Expand Down

0 comments on commit d6a65d7

Please sign in to comment.