From db9b93b2e6886b539c8f507d46a83b61bc556b19 Mon Sep 17 00:00:00 2001
From: Pavel Gross
Date: Tue, 10 Dec 2024 15:01:28 +0300
Subject: [PATCH] [#28] Client: Move CalculateObjectId from IFrostFsClient to
statis tools
Signed-off-by: Pavel Gross
---
src/FrostFS.SDK.Client/FrostFSClient.cs | 8 ------
.../Interfaces/IFrostFSClient.cs | 2 --
src/FrostFS.SDK.Client/Pool/Pool.cs | 8 ------
src/FrostFS.SDK.Client/Tools/ObjectTools.cs | 25 +++++++++++++++++--
4 files changed, 23 insertions(+), 20 deletions(-)
diff --git a/src/FrostFS.SDK.Client/FrostFSClient.cs b/src/FrostFS.SDK.Client/FrostFSClient.cs
index 9135f27..eea24fc 100644
--- a/src/FrostFS.SDK.Client/FrostFSClient.cs
+++ b/src/FrostFS.SDK.Client/FrostFSClient.cs
@@ -290,14 +290,6 @@ public class FrostFSClient : IFrostFSClient
{
return GetObjectService().SearchObjectsAsync(args, ctx);
}
-
- public FrostFsObjectId CalculateObjectId(FrostFsObjectHeader header)
- {
- if (header == null)
- throw new ArgumentNullException(nameof(header));
-
- return ObjectTools.CalculateObjectId(header, ClientCtx.Owner, ClientCtx.Version, ClientCtx.Key);
- }
#endregion
#region Session Implementation
diff --git a/src/FrostFS.SDK.Client/Interfaces/IFrostFSClient.cs b/src/FrostFS.SDK.Client/Interfaces/IFrostFSClient.cs
index 160e4e0..cce7364 100644
--- a/src/FrostFS.SDK.Client/Interfaces/IFrostFSClient.cs
+++ b/src/FrostFS.SDK.Client/Interfaces/IFrostFSClient.cs
@@ -65,6 +65,4 @@ public interface IFrostFSClient
#endregion
public Task Dial(CallContext ctx);
-
- FrostFsObjectId CalculateObjectId(FrostFsObjectHeader header);
}
diff --git a/src/FrostFS.SDK.Client/Pool/Pool.cs b/src/FrostFS.SDK.Client/Pool/Pool.cs
index 56ac3bf..3abfe60 100644
--- a/src/FrostFS.SDK.Client/Pool/Pool.cs
+++ b/src/FrostFS.SDK.Client/Pool/Pool.cs
@@ -646,14 +646,6 @@ public partial class Pool : IFrostFSClient
return client.Client!.SearchObjectsAsync(args, ctx);
}
- public FrostFsObjectId CalculateObjectId(FrostFsObjectHeader header)
- {
- if (header == null)
- throw new ArgumentNullException(nameof(header));
-
- return ObjectTools.CalculateObjectId(header, Owner, _version, Key);
- }
-
public async Task GetBalanceAsync(CallContext ctx)
{
var client = Connection();
diff --git a/src/FrostFS.SDK.Client/Tools/ObjectTools.cs b/src/FrostFS.SDK.Client/Tools/ObjectTools.cs
index fdc9a23..7abdbaf 100644
--- a/src/FrostFS.SDK.Client/Tools/ObjectTools.cs
+++ b/src/FrostFS.SDK.Client/Tools/ObjectTools.cs
@@ -1,3 +1,4 @@
+using System;
using System.Linq;
using FrostFS.Object;
@@ -9,14 +10,34 @@ using Google.Protobuf;
namespace FrostFS.SDK.Client;
-internal static class ObjectTools
+public static class ObjectTools
{
- internal static FrostFsObjectId CalculateObjectId(
+ public static FrostFsObjectId CalculateObjectId(
FrostFsObjectHeader header,
FrostFsOwner owner,
FrostFsVersion version,
ClientKey key)
{
+ if (header is null)
+ {
+ throw new ArgumentNullException(nameof(header));
+ }
+
+ if (owner is null)
+ {
+ throw new ArgumentNullException(nameof(owner));
+ }
+
+ if (version is null)
+ {
+ throw new ArgumentNullException(nameof(version));
+ }
+
+ if (key is null)
+ {
+ throw new ArgumentNullException(nameof(key));
+ }
+
var grpcHeader = CreateHeader(header, [], owner, version);
if (header.Split != null)