Skip to content

Commit

Permalink
fix(provider/gae): Delete gcs target directory in deploy.
Browse files Browse the repository at this point in the history
  • Loading branch information
jtk54 committed Oct 18, 2017
1 parent 6b0586b commit e2604b5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import com.netflix.spinnaker.clouddriver.appengine.storage.GcsStorageService
import com.netflix.spinnaker.clouddriver.appengine.storage.StorageUtils
import groovy.transform.TupleConstructor
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream
import org.apache.commons.io.FileUtils
import org.apache.commons.io.IOUtils

@TupleConstructor
Expand All @@ -46,7 +47,7 @@ class AppengineGcsRepositoryClient implements AppengineRepositoryClient {
throw new IllegalArgumentException("Repository is not a GCS bucket: " + repositoryUrl)
}

def dest = targetDirectory + File.separator + applicationDirectoryRoot
def dest = applicationDirectoryRoot ? targetDirectory + File.separator + applicationDirectoryRoot : targetDirectory

def fullPath = repositoryUrl.substring(gsPrefix.length())
if (applicationDirectoryRoot) {
Expand All @@ -56,6 +57,12 @@ class AppengineGcsRepositoryClient implements AppengineRepositoryClient {
def bucketName = fullPath.substring(0, slash)
def bucketPath = fullPath.substring(slash + 1)

// Start with a clean directory for each deployment.
File appDirectory = new File(targetDirectory)
if (appDirectory.exists() && appDirectory.isDirectory()) {
FileUtils.forceDelete(appDirectory)
}

if (fullPath.endsWith(".tar")) {
InputStream tas = storage.openObjectStream(bucketName, bucketPath)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
import org.apache.commons.compress.utils.IOUtils;
import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.FileOutputStream;
Expand Down

0 comments on commit e2604b5

Please sign in to comment.