示例#1
0
        public static ReleaseManifest Download(Region region, string name, string version, string target)
        {
            var dst = Path.Combine(target, "releasemanifest");
            var tmp = Path.Combine(target, "releasemanifest.tmp");

            while (true)
            {
                Directory.CreateDirectory(target);

                var req = WebRequest.CreateHttp(region.ReleaseManifest(name, version));
                using (var res = req.GetResponse())
                    using (var file = File.Create(tmp)) {
                        res.GetResponseStream().CopyTo(file);
                    }

                try {
                    var manifest = new ReleaseManifest(tmp);

                    File.Delete(dst);
                    File.Move(tmp, dst);

                    return(manifest);
                } catch {
                    Debug.WriteLine("Error downloading manifest, trying again...");
                    // Error while downloading //
                }
            }
        }
示例#2
0
        public ProjectPatcher(Region region, string rads, string project, string version)
        {
            this.region  = region;
            this.project = project;
            this.version = version;

            this.root = Path.Combine(rads, "projects", project);

            var releases = Path.Combine(this.root, "releases");

            target = Path.Combine(releases, version);

            if (Directory.Exists(releases))
            {
                var newest = (from dir in Directory.EnumerateDirectories(releases)
                              let ver = Version.Parse(Path.GetFileName(dir))
                                        orderby ver descending
                                        select dir).FirstOrDefault();
                if (Directory.Exists(newest))
                {
                    if (newest != target)
                    {
                        Directory.Move(newest, target);
                    }

                    var oldFile = Path.Combine(target, "releasemanifest");
                    if (File.Exists(Path.Combine(target, "S_OK")) && File.Exists(oldFile))
                    {
                        old = new ReleaseManifest(oldFile);
                    }
                }
            }

            Manifest = ReleaseManifest.Download(region, project, version, target);
        }