Skip to content

Commit

Permalink
add ChunkService.GetAllChunkFilesInDirectory method
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm360 committed Jul 29, 2024
1 parent bdc4ce2 commit 5a9041a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/BeeNet.Util/Hashing/Store/LocalDirectoryChunkStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace Etherna.BeeNet.Hashing.Store
public class LocalDirectoryChunkStore : IChunkStore
{
// Consts.
const string ChunkFileExtension = ".chunk";
public const string ChunkFileExtension = ".chunk";

// Constructor.
public LocalDirectoryChunkStore(string directoryPath, bool createDirectory = false)
Expand Down
3 changes: 3 additions & 0 deletions src/BeeNet.Util/Services/ChunkService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ public async Task<UploadEvaluationResult> EvaluateSingleFileUploadAsync(
postageStampIssuer);
}

public IEnumerable<string> GetAllChunkFilesInDirectory(string chunkStoreDirectory) =>
Directory.GetFiles(chunkStoreDirectory, '*' + LocalDirectoryChunkStore.ChunkFileExtension);

public async Task<IReadOnlyDictionary<string, string>> GetFileMetadataFromChunksAsync(
string chunkStoreDirectory,
SwarmAddress address)
Expand Down
8 changes: 8 additions & 0 deletions src/BeeNet.Util/Services/IChunkService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ Task<UploadEvaluationResult> EvaluateSingleFileUploadAsync(
int? chunkCuncorrency = null,
IChunkStore? chunkStore = null);

/// <summary>
/// Get list of all chunk files in directory
/// </summary>
/// <param name="chunkStoreDirectory">The chunk directory</param>
/// <returns>List of chunk files</returns>
IEnumerable<string> GetAllChunkFilesInDirectory(
string chunkStoreDirectory);

/// <summary>
/// Get resource metadata from a directory of chunks and the resource address
/// </summary>
Expand Down

0 comments on commit 5a9041a

Please sign in to comment.