-
-
Notifications
You must be signed in to change notification settings - Fork 54
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: Don't access disk on unknown platforms #865
Conversation
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.
I feel we could get away without changing the SentryInitialization class. If we pass down the platform through inside the SDK we can just avoid assigning the application folder (reading from Application.get...
@@ -6,5 +6,6 @@ | |||
<ProjectReference Include="../../src/sentry-dotnet/src/Sentry/Sentry.csproj" Private="false" /> | |||
<ProjectReference Include="../../src/Sentry.Unity/Sentry.Unity.csproj" Private="false" /> | |||
<ProjectReference Include="../../src/Sentry.Unity.Android/Sentry.Unity.Android.csproj" Private="false" /> | |||
<ProjectReference Include="../Sentry.Unity.Tests/Sentry.Unity.Tests.csproj" /> |
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.
I believe this can cause issues. In .NET IIRC this would return the tests twice. Does it work OK with Unity?
Often in this case we have a test helper class. e.g:
https://github.com/getsentry/sentry-dotnet/tree/main/test/Sentry.Testing
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.
It does not seem to cause any issues in Unity. We do have those SharedClasses
so we could even move it there.
I was so sure that it would be hidden behind the Switch SDK that I didn't even check for |
0fc113d
to
4e279aa
Compare
@@ -175,7 +176,10 @@ internal SentryUnityOptions(SentryMonoBehaviour behaviour, IApplication applicat | |||
? "editor" | |||
: "production"; | |||
|
|||
CacheDirectoryPath = application.PersistentDataPath.Trim(); | |||
if (application.Platform is not RuntimePlatform.Switch) |
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.
The first stab at this was through the UnknownPlatform.cs
, for any platform that's not explicitly known to work. If the issue is with creating a directory, I'd suggest moving that code here instead.
An Unknown platform is currently anything that's not iOS, macOS, windows, linux, android, webgl
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.
Fair point. I think we can use ToSentryOptions
from now on for more than just mapping from the ScriptableOptions
to the SentryOptions
.
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.
LGTM
Co-authored-by: Ivan Dlugos <6349682+vaind@users.noreply.github.com>
Apparently,
Application.persistentDataPath
not only returns a path but also creates the directory. This leads to issues on platforms that impose restrictions on fileIO, like the Switch.