Skip to content

Commit

Permalink
Batch mode: folder update count
Browse files Browse the repository at this point in the history
  • Loading branch information
sk-keeper committed Jun 29, 2024
1 parent 4feba67 commit 29fba68
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 42 deletions.
18 changes: 4 additions & 14 deletions KeeperSdk/vault/BatchVaultOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -702,11 +702,8 @@ public bool TryGetRecordByUid(string recordUid, out KeeperRecord record)
record = null;
if (_recordSet.Contains(recordUid))
{
record = _legacyRecordsToAdd.Select(x => x.Item1).FirstOrDefault(x => x.Uid == recordUid);
if (record == null)
{
record = _typedRecordsToAdd.Select(x => x.Item1).FirstOrDefault(x => x.Uid == recordUid);
}
record = (KeeperRecord)_typedRecordsToAdd.Select(x => x.Item1).FirstOrDefault(x => x.Uid == recordUid)
?? _legacyRecordsToAdd.Select(x => x.Item1).FirstOrDefault(x => x.Uid == recordUid);
}
else
{
Expand Down Expand Up @@ -1292,10 +1289,7 @@ public async Task<BatchResult> ApplyChanges()
data = JsonUtils.ParseJson<FolderData>(CryptoUtils.DecryptAesV1(existingFolder.Data.Base64UrlDecode(), folder.FolderKey));
}
}
catch
{
// ignored
}
catch {/* ignored */}

if (data == null)
{
Expand Down Expand Up @@ -1340,7 +1334,7 @@ public async Task<BatchResult> ApplyChanges()
var rq = folderUpdateRequests[i];
if (rs.IsSuccess)
{
result.UpdatedRecordCount++;
result.UpdatedFolderCount++;
}
else
{
Expand Down Expand Up @@ -1651,8 +1645,6 @@ public bool PutUserToSharedFolder(string sharedFolderUid, string userId, UserTyp
BatchLogger?.Invoke(Severity.Warning, $"Folder UID \"{sharedFolderUid}\" is not a shared folder");
}
break;
default:
break;
}

SharedFolderMember pendingMembership = null;
Expand Down Expand Up @@ -1710,8 +1702,6 @@ public bool RemoveUserFromSharedFolder(string sharedFolderUid, string userId, Us
BatchLogger?.Invoke(Severity.Warning, $"Folder UID \"{sharedFolderUid}\" is not a shared folder");
}
break;
default:
break;
}

SharedFolderMember pendingMembership = null;
Expand Down
35 changes: 7 additions & 28 deletions KeeperSdk/vault/RecordHistory.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using KeeperSecurity.Authentication;
using KeeperSecurity.Commands;
using KeeperSecurity.Utils;
using KeeperSecurity.Vault;
using KeeperSecurity.Vault.Commands;
using System;
using System.Collections.Generic;
Expand All @@ -28,15 +27,14 @@ public async Task<RecordHistory[]> GetRecordHistory(string recordUid)
};
var rs = await Auth.ExecuteAuthCommand<GetRecordHistoryCommand, GetRecordHistoryResponse>(rq);
var history = new List<RecordHistory>();
for (int i = 0; i < rs.History.Length; i++)
foreach (var rh in rs.History)
{
var rh = rs.History[i];
try
{
history.Add(new RecordHistory
{
KeeperRecord = rs.History[i].Load(r.RecordKey),
Username = rs.History[i].Username,
KeeperRecord = rh.Load(r.RecordKey),
Username = rh.Username,
});
}
catch (Exception e)
Expand Down Expand Up @@ -383,32 +381,17 @@ public class RecordHistoryStorage : IStorageRecord
public bool Shared { get; internal set; }
[DataMember(Name = "client_modified_time")]
internal double _client_modified_time;
public long ClientModifiedTime
{
get
{
return (long) _client_modified_time;
}
}
public long ClientModifiedTime => (long) _client_modified_time;

[DataMember(Name = "data")]
public string Data { get; internal set; }
[DataMember(Name = "extra")]
public string Extra { get; internal set; }


[DataMember(Name = "udata")]
public SyncDownRecordUData udata;
public string Udata
{
get
{
if (udata != null)
{
return Encoding.UTF8.GetString(JsonUtils.DumpJson(udata));
}
return null;
}
}
internal SyncDownRecordUData udata;
public string Udata => udata != null ? Encoding.UTF8.GetString(JsonUtils.DumpJson(udata)) : null;

public bool Owner { get; set; }
string IUid.Uid => RecordUid;
Expand All @@ -417,10 +400,6 @@ public string Udata
[DataContract]
internal class GetRecordHistoryResponse : KeeperApiResponse
{
public GetRecordHistoryResponse() : base()
{
}

[DataMember(Name = "history")]
public RecordHistoryStorage[] History;
}
Expand Down

0 comments on commit 29fba68

Please sign in to comment.