@@ -11,37 +11,37 @@ private[mill] class LauncherOutFilesImpl(
1111 out : os.Path ,
1212 activeCommandMessage : String ,
1313 launcherPid : Long ,
14- artifactState : LauncherArtifactState ,
14+ outFilesState : LauncherOutFilesState ,
1515 private val runId : String
1616) extends LauncherOutFiles {
1717 import LauncherOutFilesImpl .*
1818
19- private val runDir = out / LauncherArtifactState .runRootDirName / runId
19+ private val runDir = out / LauncherOutFilesState .runRootDirName / runId
2020 override val consoleTail : java.nio.file.Path = (runDir / " mill-console-tail" ).toNIO
2121 override val profile : java.nio.file.Path = (runDir / OutFiles .millProfile).toNIO
2222 override val chromeProfile : java.nio.file.Path = (runDir / OutFiles .millChromeProfile).toNIO
2323 override val dependencyTree : java.nio.file.Path = (runDir / OutFiles .millDependencyTree).toNIO
2424 override val invalidationTree : java.nio.file.Path = (runDir / OutFiles .millInvalidationTree).toNIO
2525 private val closed = new AtomicBoolean (false )
2626
27- private val publishedArtifacts = Seq (
28- PublishedArtifact (
27+ private val publishedOutFiles = Seq (
28+ PublishedOutFile (
2929 out / DaemonFiles .millConsoleTail,
3030 os.Path (consoleTail),
3131 copyFallback = false
3232 ),
33- PublishedArtifact (out / OutFiles .millProfile, os.Path (profile), copyFallback = true ),
34- PublishedArtifact (
33+ PublishedOutFile (out / OutFiles .millProfile, os.Path (profile), copyFallback = true ),
34+ PublishedOutFile (
3535 out / OutFiles .millChromeProfile,
3636 os.Path (chromeProfile),
3737 copyFallback = true
3838 ),
39- PublishedArtifact (
39+ PublishedOutFile (
4040 out / OutFiles .millDependencyTree,
4141 os.Path (dependencyTree),
4242 copyFallback = true
4343 ),
44- PublishedArtifact (
44+ PublishedOutFile (
4545 out / OutFiles .millInvalidationTree,
4646 os.Path (invalidationTree),
4747 copyFallback = true
@@ -55,29 +55,29 @@ private[mill] class LauncherOutFilesImpl(
5555 // for deletion, so the record must be visible before the directory exists.
5656 writeLauncherRunFile()
5757 os.makeDir.all(runDir)
58- cleanup(out, artifactState )
58+ cleanup(out, outFilesState )
5959
6060 override def publishLiveArtifacts (): Unit =
61- if (! closed.get()) publishLatest(publishedArtifacts .head, artifactState )
61+ if (! closed.get()) publishLatest(publishedOutFiles .head, outFilesState )
6262
6363 override def publishArtifacts (): Unit =
64- if (! closed.get()) publishedArtifacts .foreach(publishLatest(_, artifactState ))
64+ if (! closed.get()) publishedOutFiles .foreach(publishLatest(_, outFilesState ))
6565
6666 override def close (): Unit =
6767 if (closed.compareAndSet(false , true )) {
68- LauncherRecordStore .remove(out, runId)
69- cleanup(out, artifactState )
68+ LauncherOutFilesRecordStore .remove(out, runId)
69+ cleanup(out, outFilesState )
7070 }
7171
7272 private def writeLauncherRunFile (): Unit =
73- LauncherRecordStore .write(out, runId, launcherPid, activeCommandMessage)
73+ LauncherOutFilesRecordStore .write(out, runId, launcherPid, activeCommandMessage)
7474}
7575
7676private [mill] object LauncherOutFilesImpl {
7777 private val maxRetainedRuns = 10
78- private case class PublishedArtifact (link : os.Path , target : os.Path , copyFallback : Boolean )
78+ private case class PublishedOutFile (link : os.Path , target : os.Path , copyFallback : Boolean )
7979
80- private val wellKnownArtifactLinks = Seq (
80+ private val wellKnownOutFileLinks = Seq (
8181 os.RelPath (DaemonFiles .millConsoleTail),
8282 os.RelPath (OutFiles .millProfile),
8383 os.RelPath (OutFiles .millChromeProfile),
@@ -99,11 +99,11 @@ private[mill] object LauncherOutFilesImpl {
9999
100100 private def cleanup (
101101 out : os.Path ,
102- artifactState : LauncherArtifactState
102+ outFilesState : LauncherOutFilesState
103103 ): Unit = {
104104 try {
105- val active = LauncherRecordStore .sweepActive(out).iterator.map(_.runId).toSet
106- val runRootDir = out / LauncherArtifactState .runRootDirName
105+ val active = LauncherOutFilesRecordStore .sweepActive(out).iterator.map(_.runId).toSet
106+ val runRootDir = out / LauncherOutFilesState .runRootDirName
107107 if (os.exists(runRootDir)) {
108108 val runDirs = os.list(runRootDir).filter(os.isDir(_))
109109 val eligible = runDirs.filterNot(d => active.contains(d.last)).sortBy(runDirSortKey)
@@ -114,9 +114,9 @@ private[mill] object LauncherOutFilesImpl {
114114 )
115115 }
116116
117- wellKnownArtifactLinks .foreach { rel =>
117+ wellKnownOutFileLinks .foreach { rel =>
118118 val link = out / rel
119- withArtifactLock (link, artifactState ) {
119+ withPublishedPathLock (link, outFilesState ) {
120120 if (os.isLink(link) && ! os.exists(link, followLinks = true )) {
121121 try os.remove(link)
122122 catch { case _ : Throwable => () }
@@ -126,12 +126,12 @@ private[mill] object LauncherOutFilesImpl {
126126 } catch { case _ : Throwable => () }
127127 }
128128
129- private def withArtifactLock [T ](
129+ private def withPublishedPathLock [T ](
130130 link : os.Path ,
131- artifactState : LauncherArtifactState
131+ outFilesState : LauncherOutFilesState
132132 )(body : => T ): T = {
133133 val key = link.toNIO.toAbsolutePath.normalize.toString
134- artifactState.artifactLockFor (key).synchronized (body)
134+ outFilesState.publishedPathLockFor (key).synchronized (body)
135135 }
136136
137137 private def replaceAtomically (
@@ -159,40 +159,40 @@ private[mill] object LauncherOutFilesImpl {
159159 private def updateSymlink (
160160 link : os.Path ,
161161 target : os.Path ,
162- artifactState : LauncherArtifactState
162+ outFilesState : LauncherOutFilesState
163163 ): Unit = {
164164 val rel = relativizeTarget(link, target)
165165 replaceAtomically(
166166 link,
167- s " . ${link.last}.tmp- ${System .nanoTime()}- ${artifactState .nextTmpSuffix()}"
167+ s " . ${link.last}.tmp- ${System .nanoTime()}- ${outFilesState .nextTmpSuffix()}"
168168 )(tmp => os.symlink(tmp, rel))
169169 }
170170
171171 private def replaceWithCopy (
172172 link : os.Path ,
173173 target : os.Path ,
174- artifactState : LauncherArtifactState
174+ outFilesState : LauncherOutFilesState
175175 ): Unit = {
176176 replaceAtomically(
177177 link,
178- s " . ${link.last}.copy- ${System .nanoTime()}- ${artifactState .nextTmpSuffix()}"
178+ s " . ${link.last}.copy- ${System .nanoTime()}- ${outFilesState .nextTmpSuffix()}"
179179 )(tmp => os.copy.over(target, tmp, createFolders = true ))
180180 }
181181
182182 private def publishLatest (
183- artifact : PublishedArtifact ,
184- artifactState : LauncherArtifactState
183+ outFile : PublishedOutFile ,
184+ outFilesState : LauncherOutFilesState
185185 ): Unit = {
186- withArtifactLock(artifact .link, artifactState ) {
187- if (os.exists(artifact .target))
188- try updateSymlink(artifact .link, artifact .target, artifactState )
186+ withPublishedPathLock(outFile .link, outFilesState ) {
187+ if (os.exists(outFile .target))
188+ try updateSymlink(outFile .link, outFile .target, outFilesState )
189189 catch {
190190 case e : Throwable =>
191191 mill.api.Debug (
192- s " Failed to publish ${artifact .link.last} as a symlink: ${e.getClass.getSimpleName}: ${e.getMessage}"
192+ s " Failed to publish ${outFile .link.last} as a symlink: ${e.getClass.getSimpleName}: ${e.getMessage}"
193193 )
194- if (artifact .copyFallback)
195- replaceWithCopy(artifact .link, artifact .target, artifactState )
194+ if (outFile .copyFallback)
195+ replaceWithCopy(outFile .link, outFile .target, outFilesState )
196196 }
197197 }
198198 }
0 commit comments