Exemplo n.º 1
0
        // TODO: This probably actually needs Steam to close before performing actions again, as Steam caches the info and overwrites it again??
        private async Task HandleWorkshopItemMetadataRemoval(PublishedFile pf, CancellationToken cancelToken) {
            var wsf = $"appworkshop_{Id.m_AppId}.acf";
            var reg = Directories.Workshop.RootPath.GetChildFileWithName(wsf);
            MainLog.Logger.Info($"Considering rewriting {wsf}");
            if (!reg.Exists)
                return;

            var kv = await KeyValueHelper.LoadFromFileAsync(reg, cancelToken).ConfigureAwait(false);
            var changed = false;
            var key = pf.Pid.m_PublishedFileId.ToString();
            foreach (
                var root in
                new[] {
                    "WorkshopItemDetails",
                    "WorkshopItemsInstalled"
                }.Select(r => kv.GetKeyValue(r)).Where(root => root.ContainsKey(key))) {
                MainLog.Logger.Info($"Removing {key} from {root.Name}");
                root.Remove(key);
                changed = true;
            }

            if (changed) {
                MainLog.Logger.Info($"Changes detected, saving {wsf}");
                var id = kv["WorkshopItemsInstalled"];
                kv["SizeOnDisk"].Value = id.Children.Sum(x => x["size"].AsLong()).ToString();
                KeyValueHelper.SaveToFile(kv, reg);
            }
        }
Exemplo n.º 2
0
 public async Task Uninstall(PublishedFile pf, ISteamApi api,
                             CancellationToken cancelToken = default(CancellationToken))
 {
     if (!await pf.Uninstall(api, Directories.Workshop.ContentPath, cancelToken).ConfigureAwait(false))
     {
         await HandleWorkshopItemMetadataRemoval(pf, cancelToken).ConfigureAwait(false);
     }
 }
Exemplo n.º 3
0
        // TODO: This probably actually needs Steam to close before performing actions again, as Steam caches the info and overwrites it again??
        private async Task HandleWorkshopItemMetadataRemoval(PublishedFile pf, CancellationToken cancelToken)
        {
            var wsf = $"appworkshop_{Id.m_AppId}.acf";
            var reg = Directories.Workshop.RootPath.GetChildFileWithName(wsf);

            MainLog.Logger.Info($"Considering rewriting {wsf}");
            if (!reg.Exists)
            {
                return;
            }

            var kv = await KeyValueHelper.LoadFromFileAsync(reg, cancelToken).ConfigureAwait(false);

            var changed = false;
            var key     = pf.Pid.m_PublishedFileId.ToString();

            foreach (
                var root in
                new[] {
                "WorkshopItemDetails",
                "WorkshopItemsInstalled"
            }.Select(r => kv.GetKeyValue(r)).Where(root => root.ContainsKey(key)))
            {
                MainLog.Logger.Info($"Removing {key} from {root.Name}");
                root.Remove(key);
                changed = true;
            }

            if (changed)
            {
                MainLog.Logger.Info($"Changes detected, saving {wsf}");
                var id = kv["WorkshopItemsInstalled"];
                kv["SizeOnDisk"].Value = id.Children.Sum(x => x["size"].AsLong()).ToString();
                KeyValueHelper.SaveToFile(kv, reg);
            }
        }
Exemplo n.º 4
0
 public async Task Download(ISteamDownloader steamDownloader, ISteamApi steamApi, PublishedFile pf,
     Action<long?, double> action, CancellationToken cancelToken = default(CancellationToken), bool force = false) {
     if (force)
         await HandleWorkshopItemMetadataRemoval(pf, cancelToken).ConfigureAwait(false);
     await pf.Download(steamDownloader, steamApi, action, cancelToken, force).ConfigureAwait(false);
 }
Exemplo n.º 5
0
 public async Task Uninstall(PublishedFile pf, ISteamApi api,
     CancellationToken cancelToken = default(CancellationToken)) {
     if (!await pf.Uninstall(api, Directories.Workshop.ContentPath, cancelToken).ConfigureAwait(false))
         await HandleWorkshopItemMetadataRemoval(pf, cancelToken).ConfigureAwait(false);
 }
Exemplo n.º 6
0
 public async Task Download(ISteamDownloader steamDownloader, ISteamApi steamApi, PublishedFile pf,
                            Action <long?, double> action, CancellationToken cancelToken = default(CancellationToken), bool force = false)
 {
     if (force)
     {
         await HandleWorkshopItemMetadataRemoval(pf, cancelToken).ConfigureAwait(false);
     }
     await pf.Download(steamDownloader, steamApi, action, cancelToken, force).ConfigureAwait(false);
 }