Fix directory name in deploy

This commit is contained in:
Alexander Nozik 2022-06-19 21:41:51 +03:00
parent 3a25c37a47
commit fa9c042c75
No known key found for this signature in database
GPG Key ID: F7FCF2DD25C71357
2 changed files with 7 additions and 5 deletions

View File

@ -82,7 +82,7 @@ if (host != null && user != null || identity != null) {
group = "distribution" group = "distribution"
dependsOn("installDist") dependsOn("installDist")
doLast { doLast {
sshUploadDirectory(buildDir.resolve("install"), host, user, "/opt") { sshUploadDirectory(buildDir.resolve("install/spc-site"), host, user, "/opt") {
addIdentity("spc-webmaster", identity.encodeToByteArray(), null, null) addIdentity("spc-webmaster", identity.encodeToByteArray(), null, null)
} }
} }

View File

@ -25,16 +25,18 @@ private fun ChannelSftp.recursiveFolderUpload(sourceFile: File, destinationPath:
cd(destinationPath) cd(destinationPath)
var attrs: SftpATTRS? = null var attrs: SftpATTRS? = null
// check if the directory is already existing // check if the directory is already existing
val directoryPath = destinationPath + "/" + sourceFile.getName()
try { try {
attrs = stat(destinationPath + "/" + sourceFile.getName()) attrs = stat(directoryPath)
} catch (e: Exception) { } catch (e: Exception) {
println(destinationPath + "/" + sourceFile.getName() + " not found") println("$directoryPath does not exist")
} }
// else create a directory // else create a directory
if (attrs != null) { if (attrs != null) {
println("Directory exists IsDir=" + attrs.isDir()) println("Directory $directoryPath exists IsDir=${attrs.isDir()}")
} else { } else {
println("Creating dir " + sourceFile.getName()) println("Creating directory $directoryPath")
mkdir(sourceFile.getName()) mkdir(sourceFile.getName())
} }
for (f in files) { for (f in files) {