Ejemplo n.º 1
0
        public static bool UpdateCore()
        {
            bool bThrewException = false;

            string LocalModulesList = IgorUtils.DownloadFileForUpdate(IgorModulesListFilename);

            try
            {
                if (File.Exists(LocalModulesList))
                {
                    if (File.Exists(InstalledModulesListPath) && HelperDelegates.bIsValid)
                    {
                        IgorUpdater.HelperDelegates.DeleteFile(InstalledModulesListPath);
                    }

                    IgorUpdater.HelperDelegates.CopyFile(LocalModulesList, InstalledModulesListPath);
                }

                UpdatedModules.Clear();

                if (UpdateModule(CoreModuleName, false))
                {
                    return(true);
                }
            }
            catch (TimeoutException to)
            {
                if (!File.Exists(LocalModulesList))
                {
                    Debug.LogError("Igor Error: Caught exception while self-updating.  Exception is " + (to == null ? "NULL exception!" : to.ToString()));

                    bThrewException = true;

                    CleanupTemp();
                }
            }
            catch (Exception e)
            {
                Debug.LogError("Igor Error: Caught exception while updating core.  Exception is " + (e == null ? "NULL exception!" : e.ToString()));

                bThrewException = true;

                CleanupTemp();
            }

            if (!HelperDelegates.IgorJobConfig_GetWasMenuTriggered())
            {
                if (bThrewException)
                {
                    Debug.LogError("Igor Error: Exiting EditorApplication because an exception was thrown.");

                    if (HelperDelegates.bIsValid)
                    {
                        EditorApplication.Exit(-1);
                    }
                }
            }

            return(false);
        }
Ejemplo n.º 2
0
        public static void CheckIfResuming()
        {
            if (!EditorApplication.isCompiling)
            {
                bool bThrewException = false;

                EditorApplication.update -= CheckIfResuming;

                try
                {
                    FindCore();

                    if (HelperDelegates.IgorJobConfig_IsBoolParamSet("restartingfromupdate") || HelperDelegates.IgorJobConfig_IsBoolParamSet("updatebeforebuild") || Core == null)
                    {
                        HelperDelegates.IgorJobConfig_SetBoolParam("restartingfromupdate", false);

                        if (!CheckForUpdates())
                        {
                            if (HelperDelegates.IgorJobConfig_IsBoolParamSet("updatebeforebuild"))
                            {
                                HelperDelegates.IgorJobConfig_SetBoolParam("updatebeforebuild", false);

                                if (Core != null)
                                {
                                    Core.RunJobInst();
                                }
                                else
                                {
                                    Debug.LogError("Igor Error: Something went really wrong.  We don't have Igor's core, but we've already finished updating everything.  Report this with your logs please!");
                                }
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError("Igor Error: Caught exception while resuming from updates.  Exception is " + (e == null ? "NULL exception!" : e.ToString()));

                    bThrewException = true;
                }

                if (!HelperDelegates.IgorJobConfig_GetWasMenuTriggered())
                {
                    if (bThrewException)
                    {
                        Debug.LogError("Igor Error: Exiting EditorApplication because an exception was thrown.");

                        if (HelperDelegates.bIsValid)
                        {
                            EditorApplication.Exit(-1);
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public static bool UpdateModules()
        {
            bool bThrewException = false;

            try
            {
                FindCore();

                if (Core != null)
                {
                    bool bUpdated = false;

                    UpdatedModules.Clear();

                    foreach (string CurrentModule in Core.GetEnabledModuleNames())
                    {
                        bUpdated = UpdateModule(CurrentModule, false) || bUpdated;
                    }

                    if (bUpdated)
                    {
                        return(true);
                    }
                }
            }
            catch (TimeoutException)
            {
                // We should eventually handle this case by triggering a re-attempt
            }
            catch (Exception e)
            {
                Debug.LogError("Igor Error: Caught exception while updating modules.  Exception is " + (e == null ? "NULL exception!" : e.ToString()));

                bThrewException = true;

                CleanupTemp();
            }

            if (!HelperDelegates.IgorJobConfig_GetWasMenuTriggered())
            {
                if (bThrewException)
                {
                    Debug.LogError("Igor Error: Exiting EditorApplication because an exception was thrown.");

                    if (HelperDelegates.bIsValid)
                    {
                        EditorApplication.Exit(-1);
                    }
                }
            }

            return(false);
        }
Ejemplo n.º 4
0
        public static void FindCore()
        {
            if (Core == null)
            {
                List <Type> ActiveCores = HelperDelegates.GetTypesInheritFromIIgorEditorCore();

                if (ActiveCores.Count > 0)
                {
                    Core = (IIgorEditorCore)Activator.CreateInstance(ActiveCores[0]);
                }
            }
        }
Ejemplo n.º 5
0
        public static bool SelfUpdate(out bool bMajorUpgrade)
        {
            bool bThrewException = false;

            bMajorUpgrade = false;

            string InstalledFilePath = Path.Combine(BaseIgorDirectory, IgorUpdaterFilename);

            try
            {
                string LocalUpdater = IgorUtils.DownloadFileForUpdate(IgorUpdaterURL);

                if (File.Exists(LocalUpdater))
                {
                    int NewVersion      = GetVersionFromUpdaterFile(LocalUpdater);
                    int NewMajorUpgrade = GetMajorUpgradeFromUpdaterFile(LocalUpdater);

                    if (NewMajorUpgrade > MajorUpgrade)
                    {
                        bMajorUpgrade = true;
                    }

                    if (NewVersion > Version || bAlwaysUpdate)
                    {
                        if (File.Exists(InstalledFilePath))
                        {
                            IgorUpdater.HelperDelegates.DeleteFile(InstalledFilePath);
                        }

                        if (!Directory.Exists(Path.GetDirectoryName(InstalledFilePath)))
                        {
                            Directory.CreateDirectory(Path.GetDirectoryName(InstalledFilePath));
                        }

                        IgorUpdater.HelperDelegates.CopyFile(LocalUpdater, InstalledFilePath);

                        return(true);
                    }
                }
            }
            catch (TimeoutException to)
            {
                if (!File.Exists(InstalledFilePath))
                {
                    Debug.LogError("Igor Error: Caught exception while self-updating.  Exception is " + (to == null ? "NULL exception!" : to.ToString()));

                    bThrewException = true;

                    CleanupTemp();
                }
            }
            catch (Exception e)
            {
                Debug.LogError("Igor Error: Caught exception while self-updating.  Exception is " + (e == null ? "NULL exception!" : e.ToString()));

                bThrewException = true;

                CleanupTemp();
            }

            if (!HelperDelegates.IgorJobConfig_GetWasMenuTriggered())
            {
                if (bThrewException)
                {
                    Debug.LogError("Igor Error: Exiting EditorApplication because an exception was thrown.");

                    if (HelperDelegates.bIsValid)
                    {
                        EditorApplication.Exit(-1);
                    }
                }
            }

            return(false);
        }
Ejemplo n.º 6
0
        // Returns true if files were updated
        public static bool CheckForUpdates(bool bForce = false, bool bFromMenu = false, bool bSynchronous = false)
        {
            HelperDelegates.IgorJobConfig_SetWasMenuTriggered(bFromMenu);

            if (CheckForOneTimeForcedUpgrade())
            {
                MoveConfigsFromOldLocation();

                bForce = true;
            }

            if (!bDontUpdate || bForce)
            {
                UpdatedContent.Clear();

                bool bMajorUpgrade = false;

                if (!HelperDelegates.bIsValid)
                {
                    UpdateCore();

                    bMajorUpgrade = true;
                }

                bool bNeedsRebuild = bMajorUpgrade || SelfUpdate(out bMajorUpgrade);

                bNeedsRebuild = bMajorUpgrade || UpdateCore() || bNeedsRebuild;
                bNeedsRebuild = bMajorUpgrade || UpdateModules() || bNeedsRebuild;

                if (CheckForOneTimeForcedUpgrade())
                {
                    RemoveOldDirectory();

                    bNeedsRebuild = true;
                }

                if (bNeedsRebuild)
                {
                    HelperDelegates.IgorJobConfig_SetBoolParam("restartingfromupdate", true);

                    string UpdatedContentString = "The following Igor content was ";

                    if (bAlwaysUpdate)
                    {
                        UpdatedContentString += "forcibly ";
                    }

                    UpdatedContentString += "updated via ";

                    if (bLocalDownload)
                    {
                        UpdatedContentString += "local copy from " + LocalPrefix;
                    }
                    else
                    {
                        UpdatedContentString += "remote copy from GitHub";
                    }

                    UpdatedContentString += ", refreshing AssetDatabase:\n";

                    foreach (var content in UpdatedContent)
                    {
                        UpdatedContentString += content + "\n";
                    }

                    Debug.Log("Igor Log: " + UpdatedContentString);

                    ImportAssetOptions options = bSynchronous ? ImportAssetOptions.ForceSynchronousImport : ImportAssetOptions.Default;
                    AssetDatabase.Refresh(options);
                }

                return(bNeedsRebuild);
            }

            return(false);
        }