@@ -96,6 +96,7 @@ private static int Main(string[] args)
9696 {
9797 Console . Error . WriteLine ( $ "Cannot create output file for writing: { ioe . Message } ") ;
9898
99+ db . Dispose ( ) ;
99100 return 1 ;
100101 }
101102
@@ -107,24 +108,38 @@ private static int Main(string[] args)
107108 lastModCollection = collections . MaxBy ( i => i . LastModified . Ticks ) ;
108109 lastMod = lastModCollection is null ? DateTimeOffset . Now : lastModCollection . LastModified ;
109110
110- binWriter . Write ( ( int ) lastMod . Ticks ) ; // last modification date
111- binWriter . Write ( collectionCount ) ; // collection count
112-
113- foreach ( BeatmapCollection collection in collections )
111+ try
114112 {
115- binWriter . Write ( ( byte ) 0x0b ) ;
116- binWriter . Write ( collection . Name ) ; // collection name
117- binWriter . Write ( collection . BeatmapMD5Hashes . Count ) ; // beatmap count
118113
119- foreach ( string hash in collection . BeatmapMD5Hashes )
114+ binWriter . Write ( ( int ) lastMod . Ticks ) ; // last modification date
115+ binWriter . Write ( collectionCount ) ; // collection count
116+
117+ foreach ( BeatmapCollection collection in collections )
120118 {
121- binWriter . Write ( ( byte ) 0x0b ) ;
122- binWriter . Write ( hash ) ; // beatmap MD5 hash
119+ binWriter . Write ( ( byte ) 0x0b ) ;
120+ binWriter . Write ( collection . Name ) ; // collection name
121+ binWriter . Write ( collection . BeatmapMD5Hashes . Count ) ; // beatmap count
122+
123+ foreach ( string hash in collection . BeatmapMD5Hashes )
124+ {
125+ binWriter . Write ( ( byte ) 0x0b ) ;
126+ binWriter . Write ( hash ) ; // beatmap MD5 hash
127+ }
123128 }
124129 }
130+ catch ( IOException ioe )
131+ {
132+ Console . Error . WriteLine ( $ "Error writing data: { ioe . Message } ") ;
133+
134+ binWriter . Close ( ) ;
135+ outStream . Close ( ) ;
136+ db . Dispose ( ) ;
137+ return 1 ;
138+ }
125139
126140 binWriter . Close ( ) ;
127141 outStream . Close ( ) ;
142+ db . Dispose ( ) ;
128143
129144 Console . WriteLine ( "Everything is OK." ) ;
130145
0 commit comments