Beispiel #1
0
        public void InstallNode(Downloadable downloadable)
        {
            var installation = new Installation(this, this, GithubApi, Logger);
            var result       = installation.Install(downloadable);

            if (result.Success)
            {
                var reimports = Installs.Where(i => i.ConfigData.RequiresFullReimport && !i.InstallFinalized).ToArray();

                if (reimports.Any())
                {
                    var msg = "Following packages require full reimport to function properly:\n";
                    foreach (var reimport in reimports)
                    {
                        msg += reimport.ToShortString() + "\n";
                    }

                    ThreadingUtils.DispatchOnMainThread(() =>
                    {
                        if (EditorUtility.DisplayDialog("Koinonia", msg, "Ok", "No, I'll do it myself"))
                        {
                            EditorApplication.ExecuteMenuItem("Assets/Reimport All");
                        }
                        else
                        {
                            AssetDatabase.Refresh();
                        }
                    });
                }
                else
                {
                    ThreadingUtils.DispatchOnMainThread(AssetDatabase.Refresh);
                }
            }
        }
Beispiel #2
0
        public bool Update(Install install)
        {
            var host = new DownloadablesHost()
            {
                AuthorName     = install.AuthorName,
                RepositoryName = install.RepositoryName
            };

            host.FetchDownloadables();

            Downloadable update = null;

            switch (install.Type)
            {
            case DownloadableType.Branch:
                var newsetCommit = host.Downloadables.FirstOrDefault(s => s.Type == DownloadableType.Branch && s.Name == install.Name);
                if (newsetCommit == null)
                {
                    _logger.LogProblem("No commits found for branch " + install.Name);
                    return(false);
                }
                if (newsetCommit.CommitSha != install.CommitSha)
                {
                    update = newsetCommit;
                }
                else
                {
                    _logger.Log("Nothing to update");
                }
                break;

            case DownloadableType.Tag:
                _logger.LogProblem("Updating Tags is not supported. Install release instead.");
                return(false);

            case DownloadableType.Release:
                var release = host.Downloadables.FirstOrDefault(s => s.Type == DownloadableType.Release && s.AssociatedDate > install.AssociatedDate);
                if (release == null)
                {
                    _logger.Log("Nothing to update");
                    return(false);
                }
                else
                {
                    update = release;
                }

                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            if (update == null)
            {
                return(false);
            }
            _logger.Log("Will replace " + install.AssociatedDate + " with " + update.AssociatedDate);

            var uninstall = new Uninstallation(_hostsRegistry, _installsRegistry, _githubApi, _logger);

            uninstall.Uninstall(install);

            var installation = new Installation(_hostsRegistry, _installsRegistry, _githubApi, _logger);

            installation.Install(update);

            return(true);
        }