Ejemplo n.º 1
0
        public static async Task <bool> Run(string url, string _destDir, bool overwrite = false)
        {
            var inst = new Installer(_destDir);

            return(await Task.Run(() =>
            {
                var result = false;
                var archivePath = Path.Combine(inst._tempDir, "update.7z");
                var dlResult = true;

                // Only try to download URLs. We can skip this step for local files.
                if (File.Exists(url))
                {
                    archivePath = url;
                }
                else
                {
                    dlResult = inst.Download(url, archivePath);
                }

                if (dlResult && inst.Extract(archivePath))
                {
                    result = overwrite ? inst.InstallOverwrite() : inst.InstallReplace();
                    inst.Cleanup();

                    if (result)
                    {
                        inst.Display.Close();
                    }
                }

                return result;
            }));
        }
Ejemplo n.º 2
0
        public static async Task <bool> Run(string url, string destDir, string tmpName, int stripDirs = 0, bool overwrite = false)
        {
            var inst = new Installer(destDir, tmpName);

            return(await Task.Run(() =>
            {
                inst._display.Log("正在准备下载【悬浮窗插件】的组件,此窗口会出现3次,请等待下载窗口全部消失后再重启 ACT。");
                inst._display.Log("本【悬浮窗插件】是 cactbot 的必备组件。");
                inst._display.Log("--------------");
                var scVersion = Assembly.Load("SharpCompress").GetName().Version;
                if (scVersion < Version.Parse("0.24.0"))
                {
                    inst._display.Log("请先卸载 WS 悬浮窗插件!本插件可完全取代 WS 悬浮窗插件。");
                    inst._display.UpdateStatus(0, Resources.StatusError);
                    return false;
                }

                var result = false;
                var archivePath = Path.Combine(inst.TempDir, "update.file");
                var dlResult = true;

                // Only try to download URLs. We can skip this step for local files.
                if (File.Exists(url))
                {
                    archivePath = url;
                }
                else
                {
                    dlResult = inst.Download(url, archivePath);
                }

                if (dlResult && inst.Extract(archivePath, stripDirs))
                {
                    result = overwrite ? inst.InstallOverwrite() : inst.InstallReplace();
                    inst.Cleanup();

                    if (result)
                    {
                        inst.Display.Close();
                    }
                }

                return result;
            }));
        }
Ejemplo n.º 3
0
        public static async Task <bool> Run(string url, string destDir, string tmpName, int stripDirs = 0, bool overwrite = false)
        {
            var inst = new Installer(destDir, tmpName);

            return(await Task.Run(() =>
            {
                var scVersion = Assembly.Load("SharpCompress").GetName().Version;
                inst._display.Log("Current SharpCompress version: " + scVersion.ToString());
                if (scVersion < Version.Parse("0.21.1"))
                {
                    inst._display.Log(Resources.SharpCompressOutdatedError);
                    inst._display.UpdateStatus(0, Resources.StatusError);
                    return false;
                }

                var result = false;
                var archivePath = Path.Combine(inst.TempDir, "update.file");
                var dlResult = true;

                // Only try to download URLs. We can skip this step for local files.
                if (File.Exists(url))
                {
                    archivePath = url;
                }
                else
                {
                    dlResult = inst.Download(url, archivePath);
                }

                if (dlResult && inst.Extract(archivePath, stripDirs))
                {
                    result = overwrite ? inst.InstallOverwrite() : inst.InstallReplace();
                    inst.Cleanup();

                    if (result)
                    {
                        inst.Display.Close();
                    }
                }

                return result;
            }));
        }
Ejemplo n.º 4
0
        public static async Task <bool> Run(string url, string _destDir, bool overwrite = false)
        {
            var inst = new Installer(_destDir);

            return(await Task.Run(() =>
            {
                var result = false;
                var archivePath = Path.Combine(inst._tempDir, "update.7z");

                if (inst.Download(url, archivePath) && inst.Extract(archivePath))
                {
                    result = overwrite ? inst.InstallOverwrite() : inst.InstallReplace();
                    inst.Cleanup();

                    if (result)
                    {
                        inst.Display.Close();
                    }
                }

                return result;
            }));
        }
Ejemplo n.º 5
0
        public static async Task <bool> Run(string url, string _destDir, bool overwrite = false)
        {
            var inst = new Installer(_destDir);

            // We need to use a Task here since parts of Download() and the other methods are blocking.
            return(await Task.Run(async() =>
            {
                var result = false;
                var archivePath = Path.Combine(inst._tempDir, "update.7z");

                if (await inst.Download(url, archivePath) && inst.Extract(archivePath))
                {
                    result = overwrite ? inst.InstallOverwrite() : inst.InstallReplace();
                    inst.Cleanup();

                    if (result)
                    {
                        inst.Display.Close();
                    }
                }

                return result;
            }));
        }