Skip to content

Storage Exception + FileSpec Data Prop #385

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 20, 2025
Merged

Conversation

niemyjski
Copy link
Member

Needed for FoundatioFx/Foundatio.AWS#305

Didn't really see any spots to use the exception in the base library but probably should investigate that more.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds a storage-specific exception type and enriches file metadata with a flexible Data dictionary, while making minor constructor and formatting adjustments.

  • Introduce StorageException for uniform error handling in storage operations
  • Extend FileSpec to implement IHaveData and populate Data in implementations
  • Refactor expression-bodied constructors and explicit type declarations for consistency

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/Foundatio/Storage/StorageException.cs New exception class to centralize storage errors
src/Foundatio/Storage/InMemoryFileStorage.cs Expanded constructor block and changed var to byte[] for clarity
src/Foundatio/Storage/IFileStorage.cs Updated FileSpec to implement IHaveData and added Data property
src/Foundatio/Storage/FolderFileStorage.cs Populated Data with IsReadOnly and added empty Dispose block
Comments suppressed due to low confidence (1)

src/Foundatio/Storage/InMemoryFileStorage.cs:40

  • [nitpick] The empty block for the expression-bodied constructor is redundant—consider reverting to the original expression-bodied syntax for consistency with the rest of the codebase.
{

@@ -84,7 +84,8 @@ public Task<FileSpec> GetFileInfoAsync(string path)
Path = normalizedPath.Replace(Folder, String.Empty),
Created = info.CreationTimeUtc,
Modified = info.LastWriteTimeUtc,
Size = info.Length
Size = info.Length,
Data = { { "IsReadOnly", info.IsReadOnly } }
Copy link
Preview

Copilot AI May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This initialization is duplicated at line 331; consider extracting Data population into a helper method or factory to reduce duplication and ease future extensions.

Copilot uses AI. Check for mistakes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guess we may need to type this as a data dictionary for extensions? And or just don't set this here.

@niemyjski niemyjski merged commit fc9ec72 into main May 20, 2025
3 checks passed
@niemyjski niemyjski deleted the feature/storage-exception branch May 20, 2025 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants