Hi,
If the target folder (app_path/ in the case of a single tenant cartridge or
tenants/tenant_id/ in multi-tenant cartridges) is not empty when checking
out from the git repository, what is the intended behaviour that cartridge
agent follows?
In
org.apache.stratos.cartridge.agent.artifact.deployment.synchronizer.git.impl.GitBasedArtifactRepository.checkout()
method the following code segment is a bit confusing on this matter.
File gitRepoDir = new File(gitRepoCtx.getGitLocalRepoPath());
if (!gitRepoDir.exists()) {
*// this is never satisfied since gitRepoDir is created when
creating the git repo context - initGitContext()*
return cloneRepository(gitRepoCtx);
}
else {
if (isValidGitRepo(gitRepoCtx)) {
// already cloned, needs to pull
if (log.isDebugEnabled()) {
log.debug("Existing git repository detected for tenant "
+ gitRepoCtx.getTenantId() + ", no clone required");
}
return pullAndHandleErrors(gitRepoCtx);
} else {
// not a valid git repo, check if the directory is non-empty
if (gitRepoDir.list().length > 0) {
// directory is non empty. sync existing artifacts with
the remote repository
if (syncInitialLocalArtifacts(gitRepoCtx)) {
log.info("Existing local artifacts for tenant [" +
gitRepoCtx.getTenantId() + "] synchronized with remote repository
successfully");
// pull any changes from the remote repo
* // this will delete the folder and re clone if the
configuration is invalid.*
return pullAndHandleErrors(gitRepoCtx);
}
return false;
} else {
// directory is empty, clone
*// this is where the initial cloning happens*
return cloneRepository(gitRepoCtx);
}
}
}
Regards,
Chamila de Alwis
Software Engineer | WSO2 | +94772207163
Blog: code.chamiladealwis.com