@@ -118,7 +118,19 @@ public static async Task Main()
118
118
var flushPackTask = dbFile . FlushAsync ( ) . ConfigureAwait ( false ) ;
119
119
120
120
// module.json
121
- var module = new Module
121
+ Module module = null ;
122
+
123
+ try
124
+ {
125
+ await using var moduleFileR = File . Open ( MODULE_FILE , FileMode . OpenOrCreate , FileAccess . Read , FileShare . Read ) ;
126
+ module = await JsonSerializer . DeserializeAsync < Module > ( moduleFileR ) ;
127
+ }
128
+ catch ( JsonException jEx )
129
+ {
130
+ await Console . Error . WriteLineAsync ( jEx . Message ) ;
131
+ }
132
+
133
+ module ??= new Module
122
134
{
123
135
Name = root . Name ,
124
136
Title = root . Name ,
@@ -134,9 +146,15 @@ public static async Task Main()
134
146
}
135
147
} ;
136
148
137
- await using var moduleFile = File . Open ( MODULE_FILE , FileMode . Create , FileAccess . ReadWrite , FileShare . Read ) ;
138
- await JsonSerializer . SerializeAsync ( moduleFile , module , ModuleSerializationRules ) ;
139
- var flushModuleTask = moduleFile . FlushAsync ( ) . ConfigureAwait ( false ) ;
149
+ if ( Version . TryParse ( module . Version , out var ver ) )
150
+ {
151
+ // Formatting, ignore and trim Revision.
152
+ module . Version = $ "{ ver . Major } .{ ver . Minor } .{ ver . Build + 1 } ";
153
+ }
154
+
155
+ await using var moduleFileW = File . Open ( MODULE_FILE , FileMode . Create , FileAccess . ReadWrite , FileShare . Read ) ;
156
+ await JsonSerializer . SerializeAsync ( moduleFileW , module , ModuleSerializationRules ) ;
157
+ var flushModuleTask = moduleFileW . FlushAsync ( ) . ConfigureAwait ( false ) ;
140
158
141
159
await flushPackTask ;
142
160
await flushModuleTask ;
0 commit comments