Example #1
0
        public virtual void DownloadAddon(YomaConfig.YomaAddon addon) {
            var destination = FilesDir.GetChildFileWithName(addon.Url);
            var destinationUnpacked = Path.Combine(Destination.ToString(), addon.Path, addon.Pbo).ToAbsoluteFilePath();

            if (ConfirmFileValidity(destinationUnpacked, addon.Md5))
                return;

            var directory = destination.ParentDirectoryPath.ToString();
            directory.MakeSurePathExists();
            _downloader.DownloadFileAsync(Tools.Transfer.JoinUri(Url, addon.Url), destination);
        }
Example #2
0
        public virtual async Task DownloadMod(YomaConfig.YomaMod mod) {
            Config.Addons.Where(x => !File.Exists(Path.Combine(Destination.ToString(), x.Path, x.Pbo))
                                     && FilesDir.GetChildFileWithName(x.Url).Exists).ForEach(UnpackAddon);
            var remoteFiles = Config.Addons
                .Where(
                    x =>
                        !ConfirmFileValidity(Path.Combine(Destination.ToString(), x.Path, x.Pbo).ToAbsoluteFilePath(),
                            x.Md5))
                .Select(x => x.Url);

            using (var statusRepo = new StatusRepo()) {
                await _downloader.DownloadFilesAsync(new[] {Url}, statusRepo,
                    remoteFiles.ToDictionary(x => new KeyValuePair<string, Func<IAbsoluteFilePath, bool>>(x, null),
                        x => (ITransferStatus) null), FilesDir).ConfigureAwait(false);
            }
        }
Example #3
0
 public virtual void ParseConfig() {
     Config = new YomaConfig(TmpPath.GetChildFileWithName(YomaConfigFiles[0]),
         TmpPath.GetChildFileWithName(YomaConfigFiles[1]),
         TmpPath.GetChildFileWithName(YomaConfigFiles[2]));
 }
Example #4
0
        public virtual void UnpackAddon(YomaConfig.YomaAddon addon) {
            var destination = FilesDir.GetChildFileWithName(addon.Url);
            var destinationUnpacked = Path.Combine(Destination.ToString(), addon.Path, addon.Pbo).ToAbsoluteFilePath();

            var directory = destinationUnpacked.ParentDirectoryPath;
            directory.MakeSurePathExists();

            Tools.Compression.Unpack(destination, directory, true);

            if (!ConfirmFileValidity(destinationUnpacked, addon.Md5)) {
                Tools.FileUtil.Ops.DeleteWithRetry(destination.ToString());
                Tools.FileUtil.Ops.DeleteWithRetry(destinationUnpacked.ToString());
                throw new InvalidFileHash(String.Format("{0} should be {1}", destinationUnpacked, addon.Md5));
            }
        }