@@ -32,9 +32,8 @@ class Keychain : IKeychain
3232
3333 private readonly ILogging logger = Logging . GetLogger < Keychain > ( ) ;
3434
35- private readonly IEnvironment environment ;
3635 private readonly ICredentialManager credentialManager ;
37- private readonly string cachePath ;
36+ private readonly NPath cachePath ;
3837
3938 // loaded at the start of application from cached/serialized data
4039 private Dictionary < UriString , Connection > connectionCache = new Dictionary < UriString , Connection > ( ) ;
@@ -43,17 +42,14 @@ class Keychain : IKeychain
4342 private readonly Dictionary < UriString , KeychainAdapter > keychainAdapters
4443 = new Dictionary < UriString , KeychainAdapter > ( ) ;
4544
46- private IFileSystem FileSystem => environment . FileSystem ;
47-
4845 public Keychain ( IEnvironment environment , ICredentialManager credentialManager )
4946 {
5047 Guard . ArgumentNotNull ( environment , nameof ( environment ) ) ;
5148 Guard . ArgumentNotNull ( credentialManager , nameof ( credentialManager ) ) ;
5249
5350 Guard . NotNull ( environment , environment . UserCachePath , nameof ( environment . UserCachePath ) ) ;
5451
55- cachePath = environment . UserCachePath . Combine ( ConnectionFile ) . ToString ( ) ;
56- this . environment = environment ;
52+ cachePath = environment . UserCachePath . Combine ( ConnectionFile ) ;
5753 this . credentialManager = credentialManager ;
5854 }
5955
@@ -108,17 +104,17 @@ private void ReadCacheFromDisk()
108104
109105 ConnectionCacheItem [ ] connections = null ;
110106
111- if ( FileSystem . FileExists ( cachePath ) )
107+ if ( cachePath . FileExists ( ) )
112108 {
113- var json = FileSystem . ReadAllText ( cachePath ) ;
109+ var json = cachePath . ReadAllText ( ) ;
114110 try
115111 {
116112 connections = SimpleJson . DeserializeObject < ConnectionCacheItem [ ] > ( json ) ;
117113 }
118114 catch ( Exception ex )
119115 {
120116 logger . Error ( ex , "Error deserializing connection cache: {0}" , cachePath ) ;
121- FileSystem . FileDelete ( cachePath ) ;
117+ cachePath . Delete ( ) ;
122118 }
123119 }
124120
@@ -147,7 +143,7 @@ private void WriteCacheToDisk()
147143 } ) . ToArray ( ) ;
148144
149145 var json = SimpleJson . SerializeObject ( connectionCacheItems ) ;
150- FileSystem . WriteAllText ( cachePath , json ) ;
146+ cachePath . WriteAllText ( json ) ;
151147 }
152148
153149 public async Task Clear ( UriString host , bool deleteFromCredentialManager )
0 commit comments