{"record":{"id":"741aaced9ab931ff","repo":"EllanJiang/GameFramework","slug":"file-system-0-is-already-exist","errorCode":null,"errorMessage":"File system '{0}' is already exist.","messagePattern":"File system '(.+?)' is already exist\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/FileSystem/FileSystemManager.cs","lineNumber":162,"sourceCode":"            if (string.IsNullOrEmpty(fullPath))\n            {\n                throw new GameFrameworkException(\"Full path is invalid.\");\n            }\n\n            if (access == FileSystemAccess.Unspecified)\n            {\n                throw new GameFrameworkException(\"Access is invalid.\");\n            }\n\n            if (access == FileSystemAccess.Read)\n            {\n                throw new GameFrameworkException(\"Access read is invalid.\");\n            }\n\n            fullPath = Utility.Path.GetRegularPath(fullPath);\n            if (m_FileSystems.ContainsKey(fullPath))\n            {\n                throw new GameFrameworkException(Utility.Text.Format(\"File system '{0}' is already exist.\", fullPath));\n            }\n\n            FileSystemStream fileSystemStream = m_FileSystemHelper.CreateFileSystemStream(fullPath, access, true);\n            if (fileSystemStream == null)\n            {\n                throw new GameFrameworkException(Utility.Text.Format(\"Create file system stream for '{0}' failure.\", fullPath));\n            }\n\n            FileSystem fileSystem = FileSystem.Create(fullPath, access, fileSystemStream, maxFileCount, maxBlockCount);\n            if (fileSystem == null)\n            {\n                throw new GameFrameworkException(Utility.Text.Format(\"Create file system '{0}' failure.\", fullPath));\n            }\n\n            m_FileSystems.Add(fullPath, fileSystem);\n            return fileSystem;\n        }\n","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/FileSystem/FileSystemManager.cs#L144-L180","documentation":"FileSystemManager.CreateFileSystem throws this when a file system mapped to the same normalized full path is already registered in the manager's internal dictionary. The manager only allows one live file system per physical path, so creating a duplicate is rejected with a GameFrameworkException. The path is normalized (Utility.Path.GetRegularPath) before the duplicate check, so differently-formatted but equivalent paths still collide.","triggerScenarios":"Calling FileSystemManager.CreateFileSystem(fullPath, access, maxFileCount, maxBlockCount) twice with the same fullPath (or a path that normalizes to the same string) without first calling DestroyFileSystem on the existing instance.","commonSituations":"Game initialization code run more than once (e.g. re-entering a scene that calls CreateFileSystem); creating a file system for a path that was already loaded via LoadFileSystem; passing paths with different casing/separator styles that normalize to the same entry.","solutions":["Check HasFileSystem(fullPath) (or GetFileSystem) before creating, and reuse the existing IFileSystem instance.","If a fresh file system is intended, call DestroyFileSystem(existing, deletePhysicalFile:false) first, then CreateFileSystem.","Ensure only one code path initializes file systems (guard with an initialization flag)."],"exampleFix":"// before\nvar fs = fileSystemManager.CreateFileSystem(fullPath, FileSystemAccess.ReadWrite, 1024, 256);\n// after\nvar fs = fileSystemManager.HasFileSystem(fullPath)\n    ? fileSystemManager.GetFileSystem(fullPath)\n    : fileSystemManager.CreateFileSystem(fullPath, FileSystemAccess.ReadWrite, 1024, 256);","handlingStrategy":"validation","validationCode":"if (fileSystemManager.HasFileSystem(fullPath))\n    return fileSystemManager.GetFileSystem(fullPath);\nreturn fileSystemManager.CreateFileSystem(fullPath, FileSystemAccess.ReadWrite, maxFileCount, maxBlockCount);","typeGuard":null,"tryCatchPattern":"try { fs = manager.CreateFileSystem(path, access, mc, mb); }\ncatch (GameFrameworkException ex) when (ex.Message.Contains(\"is already exist\")) { fs = manager.GetFileSystem(path); }","preventionTips":["Always check HasFileSystem before CreateFileSystem.","Route all file system creation through a single service.","Remember paths are normalized before comparison - use one canonical path form."],"tags":["filesystem","duplicate-resource","gameframework"],"backgroundTag":"file-already-exists","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}