コード例 #1
0
ファイル: Repository.cs プロジェクト: aegisarma3/chimera
        private Task <bool> RunSyncItem(Manifest.SyncItem f,
                                        bool verify, bool simulate,
                                        DownloadProgressChanged dpc, DownloadEnd de, DownloadMessage dm,
                                        CancellationTokenSource cts,
                                        string overrideDestination = null)
        {
            switch (f.type)
            {
            case "rsync":
                RSyncDownloader dd = new RSyncDownloader(this);
                dd.appPath         = AppPath;
                dd.tmpPath         = TmpPath;
                dd.VerifyChecksums = verify;
                dd.Simulate        = simulate;
                return(dd.Download(LatestManifest.rsyncUrl + "/" + f.name, f, RootPath,
                                   dpc, de, dm, cts, overrideDestination));

            case "delete":
                return(Task <bool> .Run(() =>
                {
                    if (f.name.EndsWith("/") && Directory.Exists(RootPath + "/" + f.name))
                    {
                        dm.Invoke("Deleting directory " + f.name);
                        Directory.Delete(RootPath + "/" + f.name, true);
                    }
                    else if (File.Exists(RootPath + "/" + f.name))
                    {
                        dm.Invoke("Deleting file " + f.name);
                        File.Delete(RootPath + "/" + f.name);
                    }
                    return true;
                }));

            default:
                return(null);
            }
        }
コード例 #2
0
ファイル: Repository.cs プロジェクト: aegisarma3/chimera
        private Task<bool> RunSyncItem(Manifest.SyncItem f,
            bool verify, bool simulate,
            DownloadProgressChanged dpc, DownloadEnd de, DownloadMessage dm,
            CancellationTokenSource cts,
            string overrideDestination = null)
        {
            switch (f.type)
            {
                case "rsync":
                    RSyncDownloader dd = new RSyncDownloader(this);
                    dd.appPath = AppPath;
                    dd.tmpPath = TmpPath;
                    dd.VerifyChecksums = verify;
                    dd.Simulate = simulate;
                    return dd.Download(LatestManifest.rsyncUrl + "/" + f.name, f, RootPath,
                        dpc, de, dm, cts, overrideDestination);

                case "delete":
                    return Task<bool>.Run(() =>
                    {
                        if (f.name.EndsWith("/") && Directory.Exists(RootPath + "/" + f.name)) {
                            dm.Invoke("Deleting directory " + f.name);
                            Directory.Delete(RootPath + "/" + f.name, true);
                        } else if (File.Exists(RootPath + "/" + f.name)) {
                            dm.Invoke("Deleting file " + f.name);
                            File.Delete(RootPath + "/" + f.name);
                        }
                        return true;
                    });

                default:
                    return null;
            }
        }