Esempio n. 1
0
        async Task ScatterUpdate()
        {
            byte[] data = await Download(PathRouter.FileManifest);

            data            = FileLoader.RemoveBOM(data);
            newFileManifest = JsonUtility.FromJson <FileManifest>(Encoding.UTF8.GetString(data));
            newFileManifest.BuildQuery();
            HotfixLog.LogFormat("Manifest(new), files: {0}", newFileManifest.files.Count);

            var updateFiles = fileManager.CalculateUpdateFiles(newFileManifest);

            foreach (string name in updateFiles)
            {
                HotfixLog.Log("Update file: " + name);
                string file         = PathRouter.SandboxPath + name;
                string downloadFile = file + ".download";
                Directory.CreateDirectory(Path.GetDirectoryName(file));

                try
                {
                    await DownloadToFile(name, downloadFile);

                    File.Delete(file);
                    File.Move(downloadFile, file);
                    fileManager.AddFile(name);
                }
                catch (Exception e)
                {
                    File.Delete(downloadFile);
                    throw e;
                }
            }
        }
Esempio n. 2
0
        public List <string> CalculateUpdateFiles(FileManifest newManifest)
        {
            List <string> list = new List <string>();

            foreach (var entry in manifest.files)
            {
                FileEntry newEntry;
                if (newManifest.query.TryGetValue(entry.name, out newEntry))
                {
                    bool isLocal = (PathLocation.NotFound != PathRouter.Exists(entry.name));
                    if ((entry.md5 != newEntry.md5 && isLocal) ||
                        (!newEntry.remote && !isLocal))
                    {
                        list.Add(entry.name);
                    }
                }
            }
            return(list);
        }