Exemplo n.º 1
0
    /// <summary>
    /// パッチをインストールします。インストール済みの場合スキップされ True が返されます。
    /// </summary>
    public async Task <bool> InstallPatch(Patch target)
    {
        int tryCount = 0;

TryAgain:

        if (!await TryDownLoad(target.Url, target.PatchName))
        {
            if (!await TryDownLoad(target.SubUrl, target.PatchName))
            {
                return(false);
            }
        }

        LogAdd("Try UnZip [" + target.PatchName + "].");

        if (FileScaner.MakeDir(PatchFolder + target.PatchName))
        {
            try
            {
                ZipFile.ExtractToDirectory(TempFolder + target.PatchName, PatchFolder + target.PatchName, Encoding.UTF8);
                LogAdd("UnZip OK.");
            }
            catch (Exception e)
            {
                Debug.LogWarning("Error Exception : " + e);
                return(false);
            }
        }
        else
        {
            int installedFileCount = FileScaner.GetCountInFolder(PatchFolder + target.PatchName);
            LogAdd("Skip unpack. Installed [" + installedFileCount + "] Files.");
            if (target.FileCount != 0 && target.FileCount != installedFileCount) // インストール済みの数が異なる
            {
                LogAdd("Different File Error. Correct [" + target.FileCount + "] Files. Try Again.");
                UnInstallPatch(target);

                if (tryCount == 0)
                {
                    tryCount++;
                    goto TryAgain;
                }
                else
                {
                    return(false);
                }
            }
        }

        InstalledPatch.Add(target);
        return(true);
    }
Exemplo n.º 2
0
    /// <summary>
    /// 指定したパッチは既にインストール済みかを確認します。
    /// </summary>
    private bool ChackInstalledPatch(Patch target)
    {
        if (!FileScaner.ChkFile(TempFolder + target.PatchName))
        {
            return(false);
        }
        int installedFileCount = FileScaner.GetCountInFolder(PatchFolder + target.PatchName);

        LogAdd("Skip unpack. Installed [" + installedFileCount + "] Files.");
        if (target.FileCount != 0 && target.FileCount != installedFileCount)
        {
            return(false);                                                                 // インストール済みの数が異なる
        }
        return(true);
    }