{"record":{"id":"63553a6e56a2b5c7","repo":"EllanJiang/GameFramework","slug":"apply-resources-0-with-exception-1","errorCode":null,"errorMessage":"Apply resources '{0}' with exception '{1}'.","messagePattern":"Apply resources '(.+?)' with exception '(.+?)'\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourceManager.ResourceUpdater.cs","lineNumber":394,"sourceCode":"                            totalLength += resource.Length;\n                            m_ApplyWaitingInfo.Enqueue(new ApplyInfo(resourceName, updateInfo.FileSystemName, (LoadType)resource.LoadType, resource.Offset, resource.Length, resource.HashCode, resource.CompressedLength, resource.CompressedHashCode, updateInfo.ResourcePath));\n                        }\n                    }\n\n                    if (ResourceApplyStart != null)\n                    {\n                        ResourceApplyStart(m_ApplyingResourcePackPath, m_ApplyWaitingInfo.Count, totalLength);\n                    }\n                }\n                catch (Exception exception)\n                {\n                    if (m_ApplyingResourcePackStream != null)\n                    {\n                        m_ApplyingResourcePackStream.Dispose();\n                        m_ApplyingResourcePackStream = null;\n                    }\n\n                    throw new GameFrameworkException(Utility.Text.Format(\"Apply resources '{0}' with exception '{1}'.\", resourcePackPath, exception), exception);\n                }\n            }\n\n            /// <summary>\n            /// 更新指定资源组的资源。\n            /// </summary>\n            /// <param name=\"resourceGroup\">要更新的资源组。</param>\n            public void UpdateResources(ResourceGroup resourceGroup)\n            {\n                if (m_DownloadManager == null)\n                {\n                    throw new GameFrameworkException(\"You must set download manager first.\");\n                }\n\n                if (!m_CheckResourcesComplete)\n                {\n                    throw new GameFrameworkException(\"You must check resources complete first.\");\n                }","sourceCodeStart":376,"sourceCodeEnd":412,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.ResourceUpdater.cs#L376-L412","documentation":"ApplyResources failed while applying a downloaded resource pack to the local resource store. The ResourceManager disposes the partially-applied resource pack stream and throws a GameFrameworkException wrapping the original exception (e.g. IO or checksum failure). The inner exception contains the root cause.","triggerScenarios":"Calling ApplyResources(resourcePackPath) when reading or copying the resource pack stream throws: corrupted pack file, deleted/moved file mid-apply, disk full, or a stream read error during the apply operation.","commonSituations":"An interrupted download left a truncated resource pack; the file was modified between download and apply; the device ran out of storage during apply; antivirus or another process locked the file.","solutions":["Inspect the inner exception (the second argument of GameFrameworkException) to find the root cause (IO error, disk space, corrupt data).","Delete the resource pack file and re-download it, verifying checksum/length after download before calling ApplyResources.","Ensure sufficient free disk space and that no other process holds the file open, then retry ApplyResources.","Wrap the apply step so a failed pack is discarded and the app falls back to normal per-resource updating."],"exampleFix":"// before\nresourceManager.ApplyResources(corruptedPackPath);\n// after\nif (VerifyPackChecksum(corruptedPackPath, expectedHash))\n{\n    try { resourceManager.ApplyResources(corruptedPackPath); }\n    catch (GameFrameworkException ex) { File.Delete(corruptedPackPath); Log.Warning(\"Pack apply failed, re-download: {0}\", ex.InnerException); }\n}\nelse { File.Delete(corruptedPackPath); }","handlingStrategy":"try-catch","validationCode":"if (!File.Exists(packPath) || new FileInfo(packPath).Length != expectedLength) { reDownloadPack(); }","typeGuard":null,"tryCatchPattern":"try { resourceManager.ApplyResources(packPath); }\ncatch (GameFrameworkException ex)\n{\n    Log.Error(\"Apply pack '{0}' failed: {1}\", packPath, ex.InnerException?.Message);\n    File.Delete(packPath); // discard bad pack and re-download\n}","preventionTips":["Verify checksum/length of the resource pack right after download, before applying","Ensure sufficient free disk space before applying","Serialize pack-apply and group-update so they never overlap","Always inspect InnerException to distinguish IO, corruption, and space issues"],"tags":["resource-pack","io","gameframework","hot-update"],"backgroundTag":"file-read-failed","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}