@@ -19,6 +19,7 @@ public partial class StaticSettings
1919 public static string ImageAssetsDir => Path . Combine ( GamePath , _imageAssetsDir ) ;
2020 public static string MovieAssetsDir => Path . Combine ( GamePath , _movieAssetsDir ) ;
2121 public static string SkinAssetsDir => Path . Combine ( GamePath , _skinAssetsDir ) ;
22+ public static List < string > StartupErrorsList { get ; } = new ( ) ;
2223
2324 public static Config Config { get ; set ; } = new ( ) ;
2425
@@ -77,6 +78,7 @@ public List<MusicXmlWithABJacket> GetMusicList()
7778
7879 public void RescanAll ( )
7980 {
81+ StartupErrorsList . Clear ( ) ;
8082 UpdateAssetPathsFromAquaMaiConfig ( ) ;
8183 ScanMusicList ( ) ;
8284 ScanGenre ( ) ;
@@ -97,8 +99,17 @@ public void ScanMusicList()
9799 foreach ( var subDir in Directory . EnumerateDirectories ( musicDir ) )
98100 {
99101 if ( ! File . Exists ( Path . Combine ( subDir , "Music.xml" ) ) ) continue ;
100- var musicXml = new MusicXmlWithABJacket ( Path . Combine ( subDir , "Music.xml" ) , GamePath , a ) ;
101- _musicList . Add ( musicXml ) ;
102+ try
103+ {
104+ var musicXml = new MusicXmlWithABJacket ( Path . Combine ( subDir , "Music.xml" ) , GamePath , a ) ;
105+ _musicList . Add ( musicXml ) ;
106+ }
107+ catch ( Exception ex )
108+ {
109+ _logger . LogError ( ex , "加载乐曲数据 {SubDir} 失败" , subDir ) ;
110+ SentrySdk . CaptureException ( ex ) ;
111+ StartupErrorsList . Add ( $ "加载乐曲数据 { subDir } 失败: { ex . Message } ") ;
112+ }
102113 }
103114 }
104115
@@ -116,16 +127,25 @@ public void ScanGenre()
116127 {
117128 if ( ! File . Exists ( Path . Combine ( genreDir , "MusicGenre.xml" ) ) ) continue ;
118129 if ( ! Path . GetFileName ( genreDir ) . StartsWith ( "musicgenre" , StringComparison . InvariantCultureIgnoreCase ) ) continue ;
119- var id = int . Parse ( Path . GetFileName ( genreDir ) . Substring ( "musicgenre" . Length ) ) ;
120- var genreXml = new GenreXml ( id , a , GamePath ) ;
130+ try
131+ {
132+ var id = int . Parse ( Path . GetFileName ( genreDir ) . Substring ( "musicgenre" . Length ) ) ;
133+ var genreXml = new GenreXml ( id , a , GamePath ) ;
134+
135+ var existed = GenreList . Find ( it => it . Id == id ) ;
136+ if ( existed != null )
137+ {
138+ GenreList . Remove ( existed ) ;
139+ }
121140
122- var existed = GenreList . Find ( it => it . Id == id ) ;
123- if ( existed != null )
141+ GenreList . Add ( genreXml ) ;
142+ }
143+ catch ( Exception ex )
124144 {
125- GenreList . Remove ( existed ) ;
145+ _logger . LogError ( ex , "加载分类数据 {SubDir} 失败" , genreDir ) ;
146+ SentrySdk . CaptureException ( ex ) ;
147+ StartupErrorsList . Add ( $ "加载分类数据 { genreDir } 失败: { ex . Message } ") ;
126148 }
127-
128- GenreList . Add ( genreXml ) ;
129149 }
130150 }
131151
@@ -142,20 +162,29 @@ public void ScanVersionList()
142162 {
143163 if ( ! File . Exists ( Path . Combine ( versionDir , "MusicVersion.xml" ) ) ) continue ;
144164 if ( ! Path . GetFileName ( versionDir ) . StartsWith ( "musicversion" , StringComparison . InvariantCultureIgnoreCase ) ) continue ;
145- var id = int . Parse ( Path . GetFileName ( versionDir ) . Substring ( "musicversion" . Length ) ) ;
146- var versionXml = new VersionXml ( id , a , GamePath ) ;
165+ try
166+ {
167+ var id = int . Parse ( Path . GetFileName ( versionDir ) . Substring ( "musicversion" . Length ) ) ;
168+ var versionXml = new VersionXml ( id , a , GamePath ) ;
147169
148- var existed = VersionList . Find ( it => it . Id == id ) ;
149- if ( existed != null )
170+ var existed = VersionList . Find ( it => it . Id == id ) ;
171+ if ( existed != null )
172+ {
173+ VersionList . Remove ( existed ) ;
174+ }
175+
176+ VersionList . Add ( versionXml ) ;
177+ }
178+ catch ( Exception ex )
150179 {
151- VersionList . Remove ( existed ) ;
180+ _logger . LogError ( ex , "加载版本数据 {SubDir} 失败" , versionDir ) ;
181+ SentrySdk . CaptureException ( ex ) ;
182+ StartupErrorsList . Add ( $ "加载版本数据 { versionDir } 失败: { ex . Message } ") ;
152183 }
153-
154- VersionList . Add ( versionXml ) ;
155184 }
156185 }
157186
158- _logger . LogInformation ( $ "Scan version list, found { VersionList . Count } version.") ;
187+ _logger . LogInformation ( "Scan version list, found {VersionListCount } version." , VersionList . Count ) ;
159188 }
160189
161190 public void ScanAssetBundles ( )
0 commit comments