From 8d90c388226c22f0b22fdc727189c2e7c72d1bde Mon Sep 17 00:00:00 2001 From: Blake Niemyjski Date: Wed, 3 Jan 2024 21:15:59 -0600 Subject: [PATCH] Fixed storage obsolete message --- src/Foundatio/Storage/FolderFileStorage.cs | 1 + src/Foundatio/Storage/IFileStorage.cs | 8 ++++---- src/Foundatio/Storage/InMemoryFileStorage.cs | 1 + src/Foundatio/Storage/ScopedFileStorage.cs | 3 ++- src/Foundatio/Storage/StreamMode.cs | 6 +----- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Foundatio/Storage/FolderFileStorage.cs b/src/Foundatio/Storage/FolderFileStorage.cs index 1125a737..0b47ec52 100644 --- a/src/Foundatio/Storage/FolderFileStorage.cs +++ b/src/Foundatio/Storage/FolderFileStorage.cs @@ -44,6 +44,7 @@ public FolderFileStorage(Builder _serializer; + [Obsolete($"Use {nameof(GetFileStreamAsync)} with {nameof(FileAccess)} instead to define read or write behaviour of stream")] public Task GetFileStreamAsync(string path, CancellationToken cancellationToken = default) => GetFileStreamAsync(path, StreamMode.Read, cancellationToken); diff --git a/src/Foundatio/Storage/IFileStorage.cs b/src/Foundatio/Storage/IFileStorage.cs index 99f3eaa1..9518d3d7 100644 --- a/src/Foundatio/Storage/IFileStorage.cs +++ b/src/Foundatio/Storage/IFileStorage.cs @@ -11,7 +11,7 @@ namespace Foundatio.Storage { public interface IFileStorage : IHaveSerializer, IDisposable { - [Obsolete($"Use {nameof(GetFileStreamAsync)} with {nameof(FileAccess)} instead to define read or write behaviour of stream.")] + [Obsolete($"Use {nameof(GetFileStreamAsync)} with {nameof(FileAccess)} instead to define read or write behaviour of stream")] Task GetFileStreamAsync(string path, CancellationToken cancellationToken = default); /// /// Gets a file stream in the specified mode @@ -51,7 +51,7 @@ public PagedFileListResult(IReadOnlyCollection files) { HasMore = false; ((IHasNextPageFunc)this).NextPageFunc = null; } - + public PagedFileListResult(IReadOnlyCollection files, bool hasMore, Func> nextPageFunc) { Files = files; HasMore = hasMore; @@ -70,7 +70,7 @@ public PagedFileListResult(Func> nextP public async Task NextPageAsync() { if (((IHasNextPageFunc)this).NextPageFunc == null) return false; - + var result = await ((IHasNextPageFunc)this).NextPageFunc(this).AnyContext(); if (result.Success) { Files = result.Files; @@ -170,7 +170,7 @@ public static async Task> GetFileListAsync(this IF do { files.AddRange(result.Files); } while (result.HasMore && files.Count < limit.Value && await result.NextPageAsync().AnyContext()); - + return files; } } diff --git a/src/Foundatio/Storage/InMemoryFileStorage.cs b/src/Foundatio/Storage/InMemoryFileStorage.cs index bf5357f0..2500d20d 100644 --- a/src/Foundatio/Storage/InMemoryFileStorage.cs +++ b/src/Foundatio/Storage/InMemoryFileStorage.cs @@ -38,6 +38,7 @@ public InMemoryFileStorage(Builder _serializer; + [Obsolete($"Use {nameof(GetFileStreamAsync)} with {nameof(FileAccess)} instead to define read or write behaviour of stream")] public Task GetFileStreamAsync(string path, CancellationToken cancellationToken = default) => GetFileStreamAsync(path, StreamMode.Read, cancellationToken); diff --git a/src/Foundatio/Storage/ScopedFileStorage.cs b/src/Foundatio/Storage/ScopedFileStorage.cs index 4ed2e0a5..1b3515ad 100644 --- a/src/Foundatio/Storage/ScopedFileStorage.cs +++ b/src/Foundatio/Storage/ScopedFileStorage.cs @@ -20,6 +20,7 @@ public ScopedFileStorage(IFileStorage storage, string scope) { public string Scope { get; private set; } ISerializer IHaveSerializer.Serializer => UnscopedStorage.Serializer; + [Obsolete($"Use {nameof(GetFileStreamAsync)} with {nameof(FileAccess)} instead to define read or write behaviour of stream")] public Task GetFileStreamAsync(string path, CancellationToken cancellationToken = default) => GetFileStreamAsync(path, StreamMode.Read, cancellationToken); @@ -103,7 +104,7 @@ public async Task GetPagedFileListAsync(int pageSize = 100, private async Task NextPage(PagedFileListResult result) { var success = await result.NextPageAsync().AnyContext(); - + foreach (var file in result.Files) file.Path = file.Path.Substring(_pathPrefix.Length); diff --git a/src/Foundatio/Storage/StreamMode.cs b/src/Foundatio/Storage/StreamMode.cs index bdfdb2de..9c058ede 100644 --- a/src/Foundatio/Storage/StreamMode.cs +++ b/src/Foundatio/Storage/StreamMode.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Foundatio.Storage; +namespace Foundatio.Storage; /// /// Tells what the stream will be used for