stratos-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chamila De Alwis <chami...@wso2.com>
Subject Re: Handling repository target folders which are not empty
Date Fri, 19 Sep 2014 18:53:36 GMT
Hi Isuru,

In the consequent investigations I figured out the design decisions on this
scenario. Just to get further clarification, what is the use case of a
folder with already existing items?

Furthermore, the initial if statement (if (!gitRepoDir.exists())) seems to
be never reachable, because the condition would at this place always return
false.


Regards,
Chamila de Alwis
Software Engineer | WSO2 | +94772207163
Blog: code.chamiladealwis.com



On Fri, Sep 19, 2014 at 5:11 PM, Isuru Haththotuwa <isuruh@apache.org>
wrote:

> 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 <chamilad@wso2.com>
> 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/>*
>>
>>
>>

Mime
View raw message