private bool TryParseReadWriteIndexOrFail() { // If the read-write index doesn't exist. Just keep 'ReadWriteIndex' empty as it is. if (!File.Exists(m_Owner.ReadWriteIndexPath)) { return(true); } try { using (var stream = File.OpenRead(m_Owner.ReadWriteIndexPath)) { using (var br = new BinaryReader(stream)) { DeserializeAssetIndex(br, ReadWriteIndex); } } } catch (Exception e) { InternalLog.Warning($"Cannot parse the index file with exception '{e}'. Will try to clean up read-write path."); ReadWriteIndex.Clear(); return(!File.Exists(m_Owner.ReadWriteIndexPath) || m_Owner.TryCleanUpReadWritePathOrFail(Fail)); } return(true); }
private void UseInstallerResourcesOnly() { if (!m_Owner.TryCleanUpReadWritePathOrFail(Fail)) { return; } ReadWriteIndex.AssetInfos.Clear(); ReadWriteIndex.ResourceInfos.Clear(); ReadWriteIndex.ResourceGroupInfos.Clear(); ReadWriteIndex.ResourceBasicInfos.Clear(); foreach (var resourceGroupInfo in InstallerIndex.ResourceGroupInfos) { ReadWriteIndex.ResourceGroupInfos.Add(resourceGroupInfo); ResourceSummaries.Add(resourceGroupInfo.GroupId, new ResourceGroupUpdateSummary()); } foreach (var kv in InstallerIndex.AssetInfos) { ReadWriteIndex.AssetInfos.Add(kv.Key, kv.Value); } foreach (var kv in InstallerIndex.ResourceBasicInfos) { ReadWriteIndex.ResourceBasicInfos.Add(kv.Key, kv.Value); } if (!m_Owner.TrySaveReadWriteIndexOrFail(Fail)) { return; } Succeed(); }