Skip to content

Commit

Permalink
Fixed storage obsolete message
Browse files Browse the repository at this point in the history
  • Loading branch information
niemyjski committed Jan 4, 2024
1 parent 9bd841b commit 8d90c38
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/Foundatio/Storage/FolderFileStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public FolderFileStorage(Builder<FolderFileStorageOptionsBuilder, FolderFileStor
public string Folder { get; set; }
ISerializer IHaveSerializer.Serializer => _serializer;

[Obsolete($"Use {nameof(GetFileStreamAsync)} with {nameof(FileAccess)} instead to define read or write behaviour of stream")]
public Task<Stream> GetFileStreamAsync(string path, CancellationToken cancellationToken = default)
=> GetFileStreamAsync(path, StreamMode.Read, cancellationToken);

Expand Down
8 changes: 4 additions & 4 deletions src/Foundatio/Storage/IFileStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Stream> GetFileStreamAsync(string path, CancellationToken cancellationToken = default);
/// <summary>
/// Gets a file stream in the specified mode
Expand Down Expand Up @@ -51,7 +51,7 @@ public PagedFileListResult(IReadOnlyCollection<FileSpec> files) {
HasMore = false;
((IHasNextPageFunc)this).NextPageFunc = null;
}

public PagedFileListResult(IReadOnlyCollection<FileSpec> files, bool hasMore, Func<PagedFileListResult, Task<NextPageResult>> nextPageFunc) {
Files = files;
HasMore = hasMore;
Expand All @@ -70,7 +70,7 @@ public PagedFileListResult(Func<PagedFileListResult, Task<NextPageResult>> nextP
public async Task<bool> NextPageAsync() {
if (((IHasNextPageFunc)this).NextPageFunc == null)
return false;

var result = await ((IHasNextPageFunc)this).NextPageFunc(this).AnyContext();
if (result.Success) {
Files = result.Files;
Expand Down Expand Up @@ -170,7 +170,7 @@ public static async Task<IReadOnlyCollection<FileSpec>> GetFileListAsync(this IF
do {
files.AddRange(result.Files);
} while (result.HasMore && files.Count < limit.Value && await result.NextPageAsync().AnyContext());

return files;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/Foundatio/Storage/InMemoryFileStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public InMemoryFileStorage(Builder<InMemoryFileStorageOptionsBuilder, InMemoryFi
public long MaxFiles { get; set; }
ISerializer IHaveSerializer.Serializer => _serializer;

[Obsolete($"Use {nameof(GetFileStreamAsync)} with {nameof(FileAccess)} instead to define read or write behaviour of stream")]
public Task<Stream> GetFileStreamAsync(string path, CancellationToken cancellationToken = default) =>
GetFileStreamAsync(path, StreamMode.Read, cancellationToken);

Expand Down
3 changes: 2 additions & 1 deletion src/Foundatio/Storage/ScopedFileStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Stream> GetFileStreamAsync(string path, CancellationToken cancellationToken = default)
=> GetFileStreamAsync(path, StreamMode.Read, cancellationToken);

Expand Down Expand Up @@ -103,7 +104,7 @@ public async Task<PagedFileListResult> GetPagedFileListAsync(int pageSize = 100,

private async Task<NextPageResult> NextPage(PagedFileListResult result) {
var success = await result.NextPageAsync().AnyContext();

foreach (var file in result.Files)
file.Path = file.Path.Substring(_pathPrefix.Length);

Expand Down
6 changes: 1 addition & 5 deletions src/Foundatio/Storage/StreamMode.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Foundatio.Storage;
namespace Foundatio.Storage;

/// <summary>
/// Tells what the stream will be used for
Expand Down

0 comments on commit 8d90c38

Please sign in to comment.