예제 #1
0
        private async Task <List <FileDownloadInfo> > GetFileDownloadInfo()
        {
            double entries = ((ICollection)PatchData.files).Count;

            PatcherContext.UpdateMainProgress(Properties.Resources.ParsingManifest, $"0/{entries}", 0, false, true);
            var fileDownloadInfos = new List <FileDownloadInfo>();

            await Task.Delay(1);

            int entry = 0;

            // Decode filepaths into new collection
            foreach (var file in PatchData["files"])
            {
                entry++;
                PatcherContext.UpdateMainProgress(Properties.Resources.ParsingManifest, $"{entry}/{entries}", entry / entries * 100, false, true);

                var isDirectory     = false;
                var filename        = file.Name;
                var decodedFilename = DecodeFilename(filename);

                // Nexon does not intend for this file to be downloaded or this may be some other specification
                if (file.Value["objects"].Count == 0)
                {
                    Log.Info(Properties.Resources.FileWithNoObjectsIgnored, decodedFilename);
                    continue;
                }

                if (file.Value["objects"][0] == "__DIR__")
                {
                    isDirectory = true;
                }

                var fileDownloadInfo = new FileDownloadInfo(decodedFilename, file.Value["fsize"].Value,
                                                            isDirectory ? FileInfoType.Directory : FileInfoType.File);

                fileDownloadInfo.SetModifiedTimeDateTime(file.Value["mtime"].Value);

                if (isDirectory)
                {
                    continue;
                }

                for (var i = 0; i < file.Value["objects"].Count; i++)
                {
                    var filePartInfo =
                        new FilePartInfo(file.Value["objects"][i].Value, decodedFilename, file.Value["objects_fsize"][i].Value, i);
                    fileDownloadInfo.FileParts.Add(filePartInfo);
                }

                fileDownloadInfos.Add(fileDownloadInfo);
            }

            return(fileDownloadInfos);
        }
예제 #2
0
 public Patch(FileDownloadInfo fileDownloadInfo, PatchReason patchReason = PatchReason.Older)
 {
     FileDownloadInfo = fileDownloadInfo ?? throw new ArgumentNullException(nameof(fileDownloadInfo));
     PatchReason      = patchReason;
 }