Skip to content

Commit

Permalink
Remove extra SaveObject (#75)
Browse files Browse the repository at this point in the history
* Remove extra SaveObject

* fmt
  • Loading branch information
adamhathcock authored Aug 15, 2024
1 parent 70729d5 commit ea5ed87
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 86 deletions.
17 changes: 0 additions & 17 deletions src/Speckle.Sdk/Transports/DiskTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,6 @@ public void SaveObject(string id, string serializedObject)
Elapsed += stopwatch.Elapsed;
}

public void SaveObject(string id, ITransport sourceTransport)
{
CancellationToken.ThrowIfCancellationRequested();

var serializedObject = sourceTransport.GetObject(id);

if (serializedObject is null)
{
throw new TransportException(
this,
$"Cannot copy {id} from {sourceTransport.TransportName} to {TransportName} as source returned null"
);
}

SaveObject(id, serializedObject);
}

public Task WriteComplete()
{
return Task.CompletedTask;
Expand Down
10 changes: 0 additions & 10 deletions src/Speckle.Sdk/Transports/ITransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,6 @@ public interface ITransport
/// <exception cref="OperationCanceledException"><see cref="CancellationToken"/> requested cancel</exception>
public void SaveObject(string id, string serializedObject);

/// <summary>
/// <inheritdoc cref="SaveObject(string, string)"/>
/// Retrieving its serialised version from the provided transport.
/// </summary>
/// <param name="id"><inheritdoc cref="SaveObject(string, string)"/></param>
/// <param name="sourceTransport">The transport from where to retrieve it.</param>
/// <exception cref="TransportException">Failed to save object</exception>
/// <exception cref="OperationCanceledException"><see cref="CancellationToken"/> requested cancel</exception>
public void SaveObject(string id, ITransport sourceTransport);

/// <summary>
/// Awaitable method to figure out whether writing is completed.
/// </summary>
Expand Down
17 changes: 0 additions & 17 deletions src/Speckle.Sdk/Transports/Memory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,6 @@ public void SaveObject(string id, string serializedObject)
Elapsed += stopwatch.Elapsed;
}

public void SaveObject(string id, ITransport sourceTransport)
{
CancellationToken.ThrowIfCancellationRequested();

var serializedObject = sourceTransport.GetObject(id);

if (serializedObject is null)
{
throw new TransportException(
this,
$"Cannot copy {id} from {sourceTransport.TransportName} to {TransportName} as source returned null"
);
}

SaveObject(id, serializedObject);
}

public string? GetObject(string id)
{
var stopwatch = Stopwatch.StartNew();
Expand Down
18 changes: 0 additions & 18 deletions src/Speckle.Sdk/Transports/SQLite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -370,24 +370,6 @@ public void SaveObject(string id, string serializedObject)
_writeTimer.Start();
}

public void SaveObject(string id, ITransport sourceTransport)
{
CancellationToken.ThrowIfCancellationRequested();

var serializedObject = sourceTransport.GetObject(id);

if (serializedObject is null)
{
throw new TransportException(
this,
$"Cannot copy {id} from {sourceTransport.TransportName} to {TransportName} as source returned null"
);
}

//Should this just call SaveObject... do we not want the write timers?
_queue.Enqueue((id, serializedObject, Encoding.UTF8.GetByteCount(serializedObject)));
}

/// <summary>
/// Directly saves the object in the db.
/// </summary>
Expand Down
15 changes: 0 additions & 15 deletions src/Speckle.Sdk/Transports/ServerV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,21 +224,6 @@ public void SaveObject(string id, string serializedObject)
}
}

public void SaveObject(string id, ITransport sourceTransport)
{
var objectData = sourceTransport.GetObject(id);

if (objectData is null)
{
throw new TransportException(
this,
$"Cannot copy {id} from {sourceTransport.TransportName} to {TransportName} as source returned null"
);
}

SaveObject(id, objectData);
}

public void BeginWrite()
{
if (_shouldSendThreadRun || _sendingThread != null)
Expand Down
2 changes: 0 additions & 2 deletions tests/Speckle.Sdk.Serialization.Tests/TestTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ public string TransportName

public void SaveObject(string id, string serializedObject) => Objects[id] = serializedObject;

public void SaveObject(string id, ITransport sourceTransport) => throw new NotImplementedException();

public Task WriteComplete() => throw new NotImplementedException();

public string? GetObject(string id) => Objects.TryGetValue(id, out string? o) ? o : null;
Expand Down
7 changes: 0 additions & 7 deletions tests/Speckle.Sdk.Tests.Unit/Transports/TransportTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,6 @@ public async Task SaveObject_ConcurrentWrites()
}
}

[Test]
public void SaveObject_FromTransport_FailsPredictably()
{
var exception = Assert.Throws<TransportException>(() => Sut.NotNull().SaveObject("non-existent-id", Sut));
Assert.That(exception?.Transport, Is.EqualTo(Sut));
}

[Test]
public async Task ProgressAction_Called_OnSaveObject()
{
Expand Down

0 comments on commit ea5ed87

Please sign in to comment.