Beispiel #1
0
        /// <summary>
        /// Scrubs the config of mods that Steam got around to actually updating.
        /// </summary>
        private static void DoScrubConfig()
        {
            var settings = ModUpdateInfo.Settings;
            var existing = settings?.ModUpdates;
            var manager  = Global.Instance.modManager;

            if (existing != null && manager != null)
            {
                // Anything that is up to date gets purged
                var remove = HashSetPool <ModUpdateData, ModUpdateHandler> .Allocate();

                foreach (var info in existing)
                {
                    ulong id = info.ID;
                    if (CheckMod(manager, id))
                    {
                        remove.Add(info);
                    }
                    if (info.Status == ModUpdateStatus.PendingUpdate)
                    {
                        // Purge the temporary zip
                        ExtensionMethods.RemoveOldDownload(ModUpdateHandler.GetDownloadPath(id));
                        info.Status = ModUpdateStatus.UpdatedByThisMod;
                    }
                }
                // Remove the obsolete entries
                foreach (var info in remove)
                {
                    existing.Remove(info);
                }
                remove.Recycle();
                POptions.WriteSettingsForAssembly(settings);
            }
        }
Beispiel #2
0
        protected override SteamAPICall_t ExecuteDownload(PublishedFileId_t id,
                                                          out bool globalEvent)
        {
            var mod = SteamUGCServiceFixed.Instance.GetInfo(id);
            var ret = SteamAPICall_t.Invalid;

            if (mod != null)
            {
                string tempPath = ModUpdateHandler.GetDownloadPath(id.m_PublishedFileId);
                // Purge any stale temporary zip
                ExtensionMethods.RemoveOldDownload(tempPath);
#if DEBUG
                PUtil.LogDebug("Downloading mod {0:D} to {1}".F(id.m_PublishedFileId,
                                                                tempPath));
#endif
                if (mod.installPath == null)
                {
                    // Newly installed mod, populate the expected path
                    globalEvent = true;
                    SteamUGC.DownloadItem(id, false);
                }
                else
                {
                    ret = SteamRemoteStorage.UGCDownloadToLocation(mod.fileId, tempPath, 0U);
                }
            }
            globalEvent = false;
            return(ret);
        }
Beispiel #3
0
 protected override void OnError(PublishedFileId_t id, EResult result)
 {
     PUtil.LogWarning("Unable to download mod: {0:D}, code: {1}".F(id.
                                                                   m_PublishedFileId, result));
     // Purge the dead zip
     ExtensionMethods.RemoveOldDownload(ModUpdateHandler.GetDownloadPath(id.
                                                                         m_PublishedFileId));
 }
Beispiel #4
0
 public ModToUpdate(Mod mod)
 {
     Mod = mod ?? throw new ArgumentNullException("mod");
     if (mod.label.distribution_platform != Label.DistributionPlatform.Steam)
     {
         throw new ArgumentException("Only Steam mods can be updated by this class");
     }
     steamFileID = mod.GetSteamModID();
     SteamID     = steamFileID.m_PublishedFileId;
     if (!steamFileID.GetGlobalLastModified(out System.DateTime steamLastUpdate))
     {
         steamLastUpdate = System.DateTime.MinValue;
     }
     LastSteamUpdate = steamLastUpdate;
     DownloadPath    = ModUpdateHandler.GetDownloadPath(SteamID);
 }
Beispiel #5
0
        protected override void OnComplete(PublishedFileId_t id, int _)
        {
            var    mod          = SteamUGCServiceFixed.Instance.GetInfo(id);
            string path         = ModUpdateHandler.GetDownloadPath(id.m_PublishedFileId);
            bool   ok           = false;
            string expectedPath = mod.installPath;

#if DEBUG
            PUtil.LogDebug("Downloaded mod: {0:D}".F(id.m_PublishedFileId));
#endif
            if (expectedPath == null)
            {
                mod.Summon();
                expectedPath = mod.installPath;
            }
            // Copy zip to the install_path and destroy it
            if (expectedPath != null)
            {
                if (File.Exists(path))
                {
                    try {
                        File.Copy(path, expectedPath, true);
                        ok = true;
                    } catch (IOException e) {
                        PUtil.LogWarning("Unable to copy file {0} to {1}:".F(path,
                                                                             expectedPath));
                        PUtil.LogExcWarn(e);
                    } catch (UnauthorizedAccessException) {
                        PUtil.LogWarning("Access to {0} is denied!".F(expectedPath));
                    }
                    ExtensionMethods.RemoveOldDownload(path);
                }
                mod.state = SteamUGCServiceFixed.SteamModState.Updated;
                if (ok && id.GetGlobalLastModified(out System.DateTime when))
                {
                    ModUpdateDetails.UpdateConfigFor(id.m_PublishedFileId, when);
                }
            }
            else
            {
                PUtil.LogWarning("Unable to find install path for {0:D}!".F(id.
                                                                            m_PublishedFileId));
            }
        }