Skip to content

Commit 3490948

Browse files
committed
libsecret: don't write out identical creds
Avoid writing out credentials that are the same as an already existing cred.
1 parent 43b5c51 commit 3490948

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/shared/Core/Interop/Linux/SecretServiceCollection.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,16 @@ public unsafe void AddOrUpdate(string service, string account, string secret)
114114
SecretValue* secretValue = null;
115115
GError *error = null;
116116

117+
// If there is an existing credential that matches the same account and password
118+
// then don't bother writing out anything because they're the same!
119+
ICredential existingCred = Get(service, account);
120+
if (existingCred != null &&
121+
StringComparer.Ordinal.Equals(existingCred.Account, account) &&
122+
StringComparer.Ordinal.Equals(existingCred.Password, secret))
123+
{
124+
return;
125+
}
126+
117127
try
118128
{
119129
SecretService* secService = GetSecretService();

0 commit comments

Comments
 (0)