fix: user save to disk

oneRain 2021-05-07 16:27:26 +08:00
parent d76556185c
commit c28f662060
2 changed files with 10 additions and 6 deletions

View File

@ -19,7 +19,7 @@ namespace LeanCloud.Common {
} }
string path = GetFileFullPath(filename); string path = GetFileFullPath(filename);
using (FileStream fs = IOFile.OpenWrite(path)) { using (FileStream fs = IOFile.Create(path)) {
byte[] buffer = Encoding.UTF8.GetBytes(text); byte[] buffer = Encoding.UTF8.GetBytes(text);
await fs.WriteAsync(buffer, 0, buffer.Length); await fs.WriteAsync(buffer, 0, buffer.Length);
} }

View File

@ -127,9 +127,6 @@ namespace LeanCloud.Storage {
throw new ArgumentException("Cannot sign up a user that already exists."); throw new ArgumentException("Cannot sign up a user that already exists.");
} }
await Save(); await Save();
currentUser = this;
await SaveToLocal();
return this; return this;
} }
@ -555,7 +552,7 @@ namespace LeanCloud.Storage {
{ authType, data } { authType, data }
}; };
try { try {
await Save(); await base.Save();
oriAuthData[authType] = data; oriAuthData[authType] = data;
await UpdateAuthData(oriAuthData); await UpdateAuthData(oriAuthData);
} catch (Exception e) { } catch (Exception e) {
@ -570,7 +567,7 @@ namespace LeanCloud.Storage {
{ authType, null } { authType, null }
}; };
try { try {
await Save(); await base.Save();
oriAuthData.Remove(authType); oriAuthData.Remove(authType);
await UpdateAuthData(oriAuthData); await UpdateAuthData(oriAuthData);
} catch (Exception e) { } catch (Exception e) {
@ -765,5 +762,12 @@ namespace LeanCloud.Storage {
} }
return result; return result;
} }
public new async Task<LCUser> Save(bool fetchWhenSave = false, LCQuery<LCObject> query = null) {
await base.Save(fetchWhenSave, query);
currentUser = this;
await SaveToLocal();
return this;
}
} }
} }