-
-
Notifications
You must be signed in to change notification settings - Fork 475
perf(core): Create outbox and cache dirs lazily instead of during init (JAVA-613) #5792
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
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
429252a
perf(core): Create outbox and cache dirs lazily instead of during iniโฆ
runningcode 0ba52d9
changelog
runningcode 435f985
ref(core): Encapsulate lazy dir creation in a LazyDirectory value objโฆ
runningcode 648d7f2
ref(core): Inject the cache LazyDirectory via the constructor (JAVA-613)
runningcode 6b422c3
fix(core): Create the outbox dir in external envelope writers (JAVA-613)
runningcode 2dfe4e1
fix(core): Create the cache dir before writing app-start config (JAVAโฆ
runningcode 9e04ed7
ref(core): Simplify the lazy directory creation helpers (JAVA-613)
runningcode 86670d6
fix(core): Report success when losing the createDirectory race (JAVA-โฆ
runningcode bb93d87
fix(core): Don't recreate the cache dir when discarding (JAVA-613)
runningcode 1c44d83
docs(core): Note the lazy dir creation as a behavioral change (JAVA-613)
runningcode eda3158
docs(core): Explain why LazyDirectory swallows a failed mkdirs (JAVA-โฆ
runningcode 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,38 @@ | ||
| package io.sentry.util; | ||
|
|
||
| import java.io.File; | ||
| import org.jetbrains.annotations.ApiStatus; | ||
| import org.jetbrains.annotations.NotNull; | ||
|
|
||
| /** | ||
| * A filesystem directory that is created on demand rather than up front, so the (potentially | ||
| * blocking) {@code mkdirs()} runs on the thread that first writes into it instead of on the SDK | ||
| * init thread. | ||
| * | ||
| * <p>Read paths should use {@link #getFile()}, which never touches the filesystem. Write paths | ||
| * should call {@link #getOrCreate()} once before writing. Creation is not cached: on Android the | ||
| * cache dir lives under {@code Context.getCacheDir()}, which the system may wipe at any time, so | ||
| * each write re-checks. | ||
| */ | ||
| @ApiStatus.Internal | ||
| public final class LazyDirectory { | ||
|
|
||
| private final @NotNull File file; | ||
|
|
||
| public LazyDirectory(final @NotNull String path) { | ||
| this.file = new File(path); | ||
| } | ||
|
|
||
| /** Returns the directory without touching the filesystem. */ | ||
| public @NotNull File getFile() { | ||
| return file; | ||
| } | ||
|
|
||
| /** Returns the directory, creating it and any missing parents if it does not exist yet. */ | ||
| public @NotNull File getOrCreate() { | ||
| // A failed mkdirs is not reported here: callers are write paths, so the failure surfaces as the | ||
| // write error they already log and report. | ||
| FileUtils.createDirectory(file); | ||
|
runningcode marked this conversation as resolved.
|
||
| return file; | ||
| } | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.