Class DirectoryCopy
java.lang.Object
org.ek9lang.core.DirectoryCopy
- All Implemented Interfaces:
BiFunction<File, File, DirectoryCopy.CopyOutcome>
public final class DirectoryCopy
extends Object
implements BiFunction<File, File, DirectoryCopy.CopyOutcome>
THE copy of a dependency's verified unpack into a project (D-M2, P2;
docs/implementation/EK9_P2_P3_PLAN.md ยง1.3): stages a full copy of
source under a sibling
.staging-<destinationName>-<nanoTime> folder, hashing every regular file (SHA-256, lower-case hex) as
it goes, then deletes any previous destination and renames the staging folder into place over it.
This is NOT atomic on any platform - between the delete and the rename there is a window in which
destination does not exist at all (never a half-copy: the staging folder holds the full new content
until the rename, and a reader in that window simply finds destination briefly missing). A crash in
that window, or anywhere earlier, leaves only a .staging-* folder; one left behind more than
STALE_STAGING_AGE ago is removed before the NEXT copy under the same parent folder starts its own -
never a FRESH .staging-* folder, which is another process's copy still in flight. Refuses a symbolic
link anywhere in the tree (a library folder is plain files; Packager.unpack(File, File) refuses the same for an
escaping zip entry) - nothing is left of a refused copy, and destination is left exactly as it was.
Hold one.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordThe outcome of a copy: it succeeded, with the hash of every file copied; or a symbolic link refused it (refusedEntrynames its path, relative to the source); or it failed for another reason (refusedEntrysays why). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCopysource(a readable directory) into place atdestination:destination's parent is created if it does not yet exist;destinationitself is replaced atomically.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface BiFunction
andThen
-
Constructor Details
-
DirectoryCopy
public DirectoryCopy()
-
-
Method Details
-
apply
Copysource(a readable directory) into place atdestination:destination's parent is created if it does not yet exist;destinationitself is replaced atomically. A symbolic link anywhere undersourcerefuses the whole copy, leavingdestinationuntouched.- Specified by:
applyin interfaceBiFunction<File, File, DirectoryCopy.CopyOutcome>
-