Skip to content
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

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

Closed
ronsiv8 opened this issue Apr 25, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@ronsiv8
Copy link

ronsiv8 commented Apr 25, 2024

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:

  • OS: Android and windows 11, but other platforms most likely also applicable.
  • Browser: didnt test it, but most probably applicable.
@ronsiv8 ronsiv8 added the bug Something isn't working label Apr 25, 2024
@WolfgangSenff
Copy link
Collaborator

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
Copy link
Author

ronsiv8 commented Apr 25, 2024

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
Copy link
Collaborator

What happens when you try to just get the metadata?

@ronsiv8
Copy link
Author

ronsiv8 commented Apr 25, 2024

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

@WolfgangSenff
Copy link
Collaborator

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
Copy link
Author

ronsiv8 commented Apr 25, 2024

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
Copy link
Collaborator

WolfgangSenff commented May 1, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants