/// <summary> /// Gets the last modified date of a mod on Steam. /// </summary> /// <param name="id">The Steam mod ID to check.</param> /// <param name="when">The location where the last updated date will be stored.</param> /// <returns>true if the date was determined, or false if it is invalid.</returns> internal static bool GetGlobalLastModified(this PublishedFileId_t id, out System.DateTime when) { bool result = false; var inst = SteamUGCService.Instance; var steamMod = (inst == null) ? null : inst.FindMod(id); if (steamMod != null) { ulong ticks = steamMod.lastUpdateTime; result = true; when = (ticks == 0U) ? System.DateTime.MinValue : SteamVersionChecker. UnixEpochToDateTime(ticks); } else { // Mod was not found when = System.DateTime.UtcNow; } return(result); }
protected override bool CanStart(PublishedFileId_t id) { var state = (EItemState)SteamUGC.GetItemState(id); var mod = SteamUGCServiceFixed.Instance.GetInfo(id); // Start if: not installed, Steam says it needs update, or local files do not match // the Steam date bool update = (state & EItemState.k_EItemStateNeedsUpdate) != EItemState. k_EItemStateNone; if (!update && mod?.installPath != null) { update = mod.updateTimestamp.AddMinutes(SteamVersionChecker.UPDATE_JITTER) < SteamVersionChecker.UnixEpochToDateTime(mod.ugcMod.lastUpdateTime); if (update) { PUtil.LogDebug("Mod {0:D} is outdated, forcing correct download".F(id. m_PublishedFileId)); } } return((update || (state & EItemState.k_EItemStateInstalled) == EItemState. k_EItemStateNone) && (state & IS_DOWNLOADING) == EItemState.k_EItemStateNone); }
/// <summary> /// Updates the mod local update time and archive path. /// </summary> internal void Summon() { var id = ugcMod.fileId; if (SteamUGC.GetItemInstallInfo(id, out _, out installPath, 260U, out uint ts)) { updateTimestamp = SteamVersionChecker.UnixEpochToDateTime(ts); } else { installPath = null; updateTimestamp = System.DateTime.MinValue; } // But reuse the local timestamp if we updated it var ourData = ModUpdateInfo.FindModInConfig(id.m_PublishedFileId); if (ourData != null) { updateTimestamp = new System.DateTime(ourData.LastUpdated, DateTimeKind. Utc); } }
/// <summary> /// Gets the last modified date of a mod's local files. The time is returned in UTC. /// </summary> /// <param name="mod">The mod to check.</param> /// <returns>The date and time of its last modification.</returns> internal static System.DateTime GetLocalLastModified(this Mod mod) { if (mod == null) { throw new ArgumentNullException("mod"); } var label = mod.label; var result = System.DateTime.UtcNow; if (label.distribution_platform == Label.DistributionPlatform.Steam) { // 260 = MAX_PATH if (SteamUGC.GetItemInstallInfo(mod.GetSteamModID(), out _, out string _, 260U, out uint timestamp) && timestamp > 0U) { result = SteamVersionChecker.UnixEpochToDateTime(timestamp); } else { PUtil.LogWarning("Unable to get Steam install information for " + label.title); } }