-
-
Notifications
You must be signed in to change notification settings - Fork 207
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
fix: Route file writing through FileSystem
#3614
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
b2f3283
make use of 'filesystem'
bitsandfoxes ab7c7e8
Apply suggestions from code review
bitsandfoxes eea1450
loggign
bitsandfoxes 3cfce14
use filesystem everywhere
bitsandfoxes 967e006
fix tests to use fakefilesystem
bitsandfoxes cdde5d5
verify
bitsandfoxes ba1df68
debug instead of warning
bitsandfoxes 21ac35b
make it work
bitsandfoxes 12c604d
Updated CHANGELOG.md
bitsandfoxes 561903e
comment
bitsandfoxes 9f77eb7
kiss
bitsandfoxes c3ebbab
restored sample
bitsandfoxes 4da424a
make filesystem smarter
bitsandfoxes 9ae1583
split filesystem
bitsandfoxes 2803559
finished split
bitsandfoxes 88d63f0
Merge branch 'main' into fix/filesystem
bitsandfoxes aa39e58
Format code
getsentry-bot 5aba1d2
logs
bitsandfoxes e318e89
Updated CHANGELOG.md
bitsandfoxes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
using Sentry.Internal; | ||
|
||
namespace Sentry; | ||
|
||
/// <summary> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
namespace Sentry.Internal; | ||
|
||
internal abstract class FileSystemBase : IFileSystem | ||
{ | ||
public IEnumerable<string> EnumerateFiles(string path) => Directory.EnumerateFiles(path); | ||
|
||
public IEnumerable<string> EnumerateFiles(string path, string searchPattern) => | ||
Directory.EnumerateFiles(path, searchPattern); | ||
|
||
public IEnumerable<string> EnumerateFiles(string path, string searchPattern, SearchOption searchOption) => | ||
Directory.EnumerateFiles(path, searchPattern, searchOption); | ||
|
||
public bool DirectoryExists(string path) => Directory.Exists(path); | ||
|
||
public bool FileExists(string path) => File.Exists(path); | ||
|
||
public DateTimeOffset GetFileCreationTime(string path) => new FileInfo(path).CreationTimeUtc; | ||
|
||
public string ReadAllTextFromFile(string path) => File.ReadAllText(path); | ||
|
||
public Stream OpenFileForReading(string path) => File.OpenRead(path); | ||
|
||
public abstract FileOperationResult CreateDirectory(string path); | ||
public abstract FileOperationResult DeleteDirectory(string path, bool recursive = false); | ||
public abstract FileOperationResult CreateFileForWriting(string path, out Stream fileStream); | ||
public abstract FileOperationResult WriteAllTextToFile(string path, string contents); | ||
public abstract FileOperationResult MoveFile(string sourceFileName, string destFileName, bool overwrite = false); | ||
public abstract FileOperationResult DeleteFile(string path); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
namespace Sentry.Internal; | ||
|
||
internal class ReadOnlyFileSystem : FileSystemBase | ||
{ | ||
public override FileOperationResult CreateDirectory(string path) => FileOperationResult.Disabled; | ||
|
||
public override FileOperationResult DeleteDirectory(string path, bool recursive = false) => FileOperationResult.Disabled; | ||
|
||
public override FileOperationResult CreateFileForWriting(string path, out Stream fileStream) | ||
{ | ||
fileStream = Stream.Null; | ||
return FileOperationResult.Disabled; | ||
} | ||
|
||
public override FileOperationResult WriteAllTextToFile(string path, string contents) => FileOperationResult.Disabled; | ||
|
||
public override FileOperationResult MoveFile(string sourceFileName, string destFileName, bool overwrite = false) => | ||
FileOperationResult.Disabled; | ||
|
||
public override FileOperationResult DeleteFile(string path) => FileOperationResult.Disabled; | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this couldn’t have
using
anymore? I’m concerned an exception will keep dangling filesa