Hi Chamila, Please check the code segment under the comment 'directory is non empty. sync existing artifacts with the remote repository'. It handles the non-empty directory scenario. Or am I mistaken about your requirement?
On Fri, Sep 19, 2014 at 3:41 PM, Chamila De Alwis <[email protected]> wrote: > 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 > > -- > <http://code.chamiladealwis.com> > Thanks and Regards, > > Isuru H. > <http://code.chamiladealwis.com> > +94 716 358 048 <http://code.chamiladealwis.com>* <http://wso2.com/>* > > > * <http://wso2.com/>* > > > * <http://wso2.com/>* > > >
