GodotNuts / GodotFirebase

Implementations of Firebase for Godot using GDScript
MIT License
517 stars 74 forks source link

[BUG] Firebase Storage: A StorageRefrence is valid even though the file it refrences does not exist. #395

Closed ronsiv8 closed 2 months ago

ronsiv8 commented 3 months ago

Describe the bug When getting a storagerefrence to a file, in my program that file can sometimes not exist. The boolean valid in StorageRefrence is perfect for this, however, when using it, it seems that the file that doesnt exist is still valid.

To Reproduce Steps to reproduce the behavior: Attempt to get a reference of a nonexistant file. Check the valid boolean value.

Expected behavior The boolean value is true. Additionally, when trying to load the file, the firebase script runs into the following error: Invalid get index 'downloadTokens' (on base: 'Dictionary'). -> on line 195 of the FirebaseStorage script.

Environment:

WolfgangSenff commented 3 months ago

Hm. Very weird. I'll have to look into this. I'm not sure we can do anything about the first bug - unless it has tried to get the file, the Godot code can't know whether or not it exists in Firebase. But maybe there's something, not sure, like an "exists" function.

ronsiv8 commented 3 months ago

I'd really appreciate it. As of now, I came up with a scuffed-as-all-hell solution, but it is nothing im happy with, thats for sure.

WolfgangSenff commented 3 months ago

What happens when you try to just get the metadata?

ronsiv8 commented 3 months ago

I'm gonna have to get back to you on that one tomorrow, i've got to head out now

WolfgangSenff commented 3 months ago

Been looking around, seems like there is no way to solve that problem. Our own valid property is used for after a file is deleted, nothing more. Apparently what you'd have to do is call list, then manually look for the file client-side.

How I've handled such a thing before is to make a Firestore reference document that holds onto metadata (in the traditional sense, rather than what Firebase Storage says is metadata). Then I can just ask to see if the document exists and if not, then don't attempt to get it. It's ugly, but doable.

ronsiv8 commented 3 months ago

The project im working on has a server with the firebase admin api. I think ill just use that to check if images exist and share around download links. Its pretty odd that no exists function... Uhh, exists.

WolfgangSenff commented 2 months ago

I completely agree! I'll see if I can ask the Firebase team to add it. Closing this for now.