File tree 5 files changed +57
-14
lines changed
5 files changed +57
-14
lines changed Original file line number Diff line number Diff line change @@ -24,21 +24,19 @@ public static async Task LoadSettingsAsync()
24
24
var path = Path . Combine ( AppDomain . CurrentDomain . BaseDirectory , "Config/UserSettings.json" ) ;
25
25
if ( File . Exists ( path ) )
26
26
{
27
- await PerformRead ( path ) . ConfigureAwait ( false ) ;
28
- }
29
- else
30
- {
31
- // TODO test saving location for macOS https://johnkoerner.com/csharp/special-folder-values-on-windows-versus-mac/
32
- var appData = Path . Combine ( Environment . GetFolderPath ( Environment . SpecialFolder . ApplicationData ) , "Ruben2776/PicView/Config/UserSettings.json" ) ;
33
- if ( File . Exists ( appData ) )
27
+ try
34
28
{
35
- await PerformRead ( appData ) . ConfigureAwait ( false ) ;
29
+ await PerformRead ( path ) . ConfigureAwait ( false ) ;
36
30
}
37
- else
31
+ catch ( Exception )
38
32
{
39
- SetDefaults ( ) ;
33
+ await Retry ( ) . ConfigureAwait ( false ) ;
40
34
}
41
35
}
36
+ else
37
+ {
38
+ await Retry ( ) . ConfigureAwait ( false ) ;
39
+ }
42
40
}
43
41
catch ( Exception ex )
44
42
{
@@ -47,6 +45,28 @@ public static async Task LoadSettingsAsync()
47
45
#endif
48
46
SetDefaults ( ) ;
49
47
}
48
+ return ;
49
+
50
+ async Task Retry ( )
51
+ {
52
+ // TODO test saving location for macOS https://johnkoerner.com/csharp/special-folder-values-on-windows-versus-mac/
53
+ var appData = Path . Combine ( Environment . GetFolderPath ( Environment . SpecialFolder . ApplicationData ) , "Ruben2776/PicView/Config/UserSettings.json" ) ;
54
+ if ( File . Exists ( appData ) )
55
+ {
56
+ try
57
+ {
58
+ await PerformRead ( appData ) . ConfigureAwait ( false ) ;
59
+ }
60
+ catch ( Exception )
61
+ {
62
+ SetDefaults ( ) ;
63
+ }
64
+ }
65
+ else
66
+ {
67
+ SetDefaults ( ) ;
68
+ }
69
+ }
50
70
}
51
71
52
72
private static void SetDefaults ( )
Original file line number Diff line number Diff line change 1
1
using System . Diagnostics ;
2
+ using System . Runtime ;
2
3
3
4
namespace PicView . Core . Navigation ;
4
5
@@ -28,6 +29,14 @@ public FileHistory()
28
29
}
29
30
catch ( Exception e )
30
31
{
32
+ try
33
+ {
34
+ _fileLocation = Path . Combine ( Environment . GetFolderPath ( Environment . SpecialFolder . ApplicationData ) , "Ruben2776/PicView/Config/recent.txt" ) ;
35
+ }
36
+ catch ( Exception )
37
+ {
38
+ Trace . WriteLine ( $ "{ nameof ( FileHistory ) } exception, \n { e . Message } ") ;
39
+ }
31
40
#if DEBUG
32
41
Trace . WriteLine ( $ "{ nameof ( FileHistory ) } exception, \n { e . Message } ") ;
33
42
#endif
Original file line number Diff line number Diff line change @@ -9,8 +9,20 @@ public partial class App
9
9
{
10
10
protected override void OnStartup ( StartupEventArgs e )
11
11
{
12
- ProfileOptimization . SetProfileRoot ( Path . Combine ( AppDomain . CurrentDomain . BaseDirectory , "Config/" ) ) ;
13
- ProfileOptimization . StartProfile ( "ProfileOptimization" ) ;
12
+ Task . Run ( ( ( ) =>
13
+ {
14
+ try
15
+ {
16
+ ProfileOptimization . SetProfileRoot ( Path . Combine ( AppDomain . CurrentDomain . BaseDirectory , "Config/" ) ) ;
17
+ ProfileOptimization . StartProfile ( "ProfileOptimization" ) ;
18
+ }
19
+ catch ( Exception )
20
+ {
21
+ ProfileOptimization . SetProfileRoot ( Path . Combine ( Environment . GetFolderPath ( Environment . SpecialFolder . ApplicationData ) , "Ruben2776/PicView/Config/" ) ) ;
22
+ ProfileOptimization . StartProfile ( "ProfileOptimization" ) ;
23
+ }
24
+ } ) ) ;
25
+
14
26
DispatcherUnhandledException += App_DispatcherUnhandledException ;
15
27
}
16
28
Original file line number Diff line number Diff line change @@ -52,7 +52,10 @@ internal static async Task OpenLastFileAsync()
52
52
{
53
53
if ( File . Exists ( Path . Combine ( AppDomain . CurrentDomain . BaseDirectory , "Config/recent.txt" ) ) == false )
54
54
{
55
- return ;
55
+ if ( File . Exists ( Path . Combine ( Environment . GetFolderPath ( Environment . SpecialFolder . ApplicationData ) , "Ruben2776/PicView/Config/recent.txt" ) ) == false )
56
+ {
57
+ return ;
58
+ }
56
59
}
57
60
58
61
await ConfigureWindows . GetMainWindow . Dispatcher . InvokeAsync ( ( ) =>
Original file line number Diff line number Diff line change 1
1
using PicView . Core . Config ;
2
2
using PicView . Core . FileHandling ;
3
3
using PicView . Core . Gallery ;
4
- using PicView . Core . Navigation ;
5
4
using PicView . WPF . FileHandling ;
6
5
using PicView . WPF . ImageHandling ;
7
6
using PicView . WPF . PicGallery ;
You can’t perform that action at this time.
0 commit comments