Skip to content

Commit

Permalink
Improve ObjectStore root config handling (#8445)
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin-Molinero authored Dec 4, 2024
1 parent a2efee8 commit 9955892
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Engine/Storage/LocalObjectStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class LocalObjectStore : IObjectStore
/// <summary>
/// Gets the default object store location
/// </summary>
public static string DefaultObjectStore => Path.GetFullPath(Config.Get("object-store-root", "./storage"));
public static string DefaultObjectStore { get; set; } = Path.GetFullPath(Config.Get("object-store-root", "./storage"));

/// <summary>
/// Flag indicating the state of this object storage has changed since the last <seealso cref="Persist"/> invocation
Expand Down
8 changes: 3 additions & 5 deletions Tests/Common/Storage/LocalObjectStoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
using QuantConnect.Storage;
using QuantConnect.Research;
using System.Collections.Generic;
using QuantConnect.Configuration;
using QuantConnect.Lean.Engine.Storage;
using System.Threading;

Expand All @@ -33,15 +32,15 @@ namespace QuantConnect.Tests.Common.Storage
public class LocalObjectStoreTests
{
private static readonly string TestStorageRoot = $"{Directory.GetCurrentDirectory()}/{nameof(LocalObjectStoreTests)}";
private static readonly string StorageRootConfigurationValue = Config.Get("object-store-root");
private static readonly string StorageRootConfigurationValue = LocalObjectStore.DefaultObjectStore;

private ObjectStore _store;
private ILogHandler _logHandler;

[OneTimeSetUp]
public void Setup()
{
Config.Set("object-store-root", TestStorageRoot);
LocalObjectStore.DefaultObjectStore = TestStorageRoot;
#pragma warning disable CA2000
_store = new ObjectStore(new TestLocalObjectStore());
#pragma warning restore CA2000
Expand All @@ -55,15 +54,14 @@ public void Setup()
public void Cleanup()
{
_store.DisposeSafely();
Config.Set("object-store-root", StorageRootConfigurationValue);
LocalObjectStore.DefaultObjectStore = StorageRootConfigurationValue;
try
{
Directory.Delete(TestStorageRoot, true);
}
catch
{
}
Config.Reset();

// Restore initial Log Handler
Log.LogHandler = _logHandler;
Expand Down

0 comments on commit 9955892

Please sign in to comment.