File tree Expand file tree Collapse file tree 1 file changed +13
-12
lines changed
Flow.Launcher.Infrastructure/Storage Expand file tree Collapse file tree 1 file changed +13
-12
lines changed Original file line number Diff line number Diff line change @@ -66,8 +66,17 @@ public async ValueTask<T> TryLoadAsync(T defaultData)
6666 await SaveAsync ( ) ;
6767 }
6868
69- await using var stream = new FileStream ( FilePath , FileMode . Open ) ;
70- Data = await DeserializeAsync ( stream , defaultData ) ;
69+ try
70+ {
71+ await using var stream = new FileStream ( FilePath , FileMode . Open ) ;
72+ Data = await DeserializeAsync ( stream , defaultData ) ;
73+ }
74+ catch ( System . Exception e )
75+ {
76+ Log . Exception ( ClassName , $ "Failed to load stream and deserialize for <{ FilePath } >", e ) ;
77+ Data = defaultData ;
78+ return defaultData ;
79+ }
7180 }
7281 else
7382 {
@@ -81,16 +90,8 @@ public async ValueTask<T> TryLoadAsync(T defaultData)
8190
8291 private static async ValueTask < T > DeserializeAsync ( Stream stream , T defaultData )
8392 {
84- try
85- {
86- var t = await MemoryPackSerializer . DeserializeAsync < T > ( stream ) ;
87- return t ?? defaultData ;
88- }
89- catch ( System . Exception )
90- {
91- // Log.Exception($"|BinaryStorage.Deserialize|Deserialize error for file <{FilePath}>", e);
92- return defaultData ;
93- }
93+ var t = await MemoryPackSerializer . DeserializeAsync < T > ( stream ) ;
94+ return t ?? defaultData ;
9495 }
9596
9697 public void Save ( )
You can’t perform that action at this time.
0 commit comments