rename parameters createSymlink

This commit is contained in:
ansgarz 2022-05-17 18:43:55 +02:00
parent a881310f48
commit eb514fb8aa
2 changed files with 13 additions and 13 deletions

View file

@ -341,20 +341,20 @@ fun Prov.deleteDir(dir: String, path: String, sudo: Boolean = false): ProvResult
* Creates and validates a symlink.
*/
fun Prov.createSymlink(
source: File,
target: File,
originalFile: File,
link: File,
sudo: Boolean = false,
overwriteIfExisting: Boolean = true,
createTargetDirIfMissing: Boolean = true,
createLinkDirIfMissing: Boolean = true,
): ProvResult = task {
if (createTargetDirIfMissing) {
createParentDir(target, sudo)
if (createLinkDirIfMissing) {
createParentDir(link, sudo)
}
val overwriteFlag = if (overwriteIfExisting) "f" else ""
cmd("ln -s$overwriteFlag $source $target", sudo = sudo)
cmd("ln -s$overwriteFlag $originalFile $link", sudo = sudo)
// ensure link works
taskWithResult("validate link") {
ProvResult(checkFile(target.toString(), sudo = sudo))
ProvResult(checkFile(link.toString(), sudo = sudo))
}
}

View file

@ -415,8 +415,8 @@ internal class FilesystemKtTest {
fun test_createLink_without_dir() {
// given
val prov = defaultTestContainer()
val source = File("testlinksource")
val target = File("testlinktarget")
val source = File("testoriginalfile")
val target = File("testlink")
prov.createFile(source.toString(), "textinlinkfile")
// when
@ -436,8 +436,8 @@ internal class FilesystemKtTest {
fun test_createLink_with_dirs() {
// given
val prov = defaultTestContainer()
val source = File("~/linksourcedir/testlinksource2")
val target = File("linkdir1/linkdir2/testlinktarget2")
val source = File("~/linkoriginalfiledir/testoriginalfile2")
val target = File("linkdir1/linkdir2/testlink2")
prov.createFile(source.toString(), "textinlinkfile2")
// when
@ -457,8 +457,8 @@ internal class FilesystemKtTest {
fun test_createLink_with_dirs_and_sudo() {
// given
val prov = defaultTestContainer()
val source = File("/linksourcedirsudo/linksourcefilesudo")
val target = File("/linkdir1sudo/linkdir2sudo/linksudo")
val source = File("~/linkoriginalfiledirsudo/testoriginalfilesudo")
val target = File("linkdir1sudo/linkdir2sudo/testlinksudo")
prov.createFile(source.toString(), "textinlinkfilesudo", sudo = true)
// when