question

Manuel Rauber avatar image
Manuel Rauber asked

[Unity] Potential issue in PlayFab Editor Extension that could delete the whole project

Hi!

In Unity, we've a nice panel with a button to upgrade the SDK.

If you press the button, it will execute the upgrade. First, it will delete the old PlayFabSDK folder and download the current one.

The code to delete is this one here: https://github.com/PlayFab/UnitySDK/blob/master/ExampleTestProject/Assets/PlayFabEditorExtensions/Editor/Scripts/Panels/PlayFabEditorSDKTools.cs#L376

So, for whatever reason, in my current project "PlayFabEditorPrefsSO.Instance.SdkPath" was an empty string (or null).

If you put an empty string or null into Unity's FileUtil.DeleteFileOrDirectory-method it will simply delete your whole project. Unity will crash and if you re-open the project, all you get is an empty 3D template. Everything else is gone, even folders like ".git" etc.

IMHO the PlayFab Editor Extensions should check on delete again, if the file path is correct or at least it's not an empty string to not delete the whole project. :-)

I have no idea, why the SdkPath was empty string or null, but as written, the extension should at least check, it's not the case, when deleting the SDK.

unity3d
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Seth Du avatar image
Seth Du answered

When upgrading SDK, in the common scenario SdkPath shouldn't be empty because there is a function named FindSdkAsset to locate the exact directory.

However, your concern is valid, and I believe it will be more appropriate to add a value check before deletion. For now, I can only suggest send a thread on the Feature Request forum -- https://community.playfab.com/spaces/24/index.html

3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Manuel Rauber avatar image Manuel Rauber commented ·

I will do so, but honestly...

It's a simple "if (string.IsNullOrWhitespace(SdkPath))" and the issue is gone.
No idea what that needs a "Feature Request", because it's not a feature, its to prevent deleting the whole project if the FindSdkAsset resolves to empty string.

0 Likes 0 ·
Seth Du avatar image Seth Du ♦ Manuel Rauber commented ·

Please understand it is the standard procedure for this kind of request. Please also feel free to submit a pull request on GitHub. Thanks for your understanding.

0 Likes 0 ·
Manuel Rauber avatar image Manuel Rauber Seth Du ♦ commented ·

Oh, PR is fine for me. I will create one, thanks!

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.