Skip to content
Merged

Dev #29

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions addons/supabase/Auth/auth.gd
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ func _on_task_completed(task : AuthTask) -> void:
_expires_in = 0
elif task.error != null:
emit_signal("error", task.error)
_pooled_tasks.erase(task)


# A timer used to listen through TCP on the redirect uri of the request
Expand Down
8 changes: 7 additions & 1 deletion addons/supabase/Storage/storage.gd
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ func _init(config : Dictionary) -> void:
_config = config
name = "Storage"

func _ready() -> void:
var buckets : Node = Node.new()
buckets.set_name("Buckets")
add_child(buckets)

func list_buckets() -> StorageTask:
_bearer = Supabase.auth._bearer
var endpoint : String = _config.supabaseUrl + _rest_endpoint + "bucket"
Expand Down Expand Up @@ -97,7 +102,7 @@ func delete_bucket(id : String) -> StorageTask:


func from(id : String) -> StorageBucket:
for bucket in get_children():
for bucket in get_node("Buckets").get_children():
if bucket.id == id:
return bucket
var storage_bucket : StorageBucket = StorageBucket.new(id, _config)
Expand Down Expand Up @@ -126,3 +131,4 @@ func _on_task_completed(task : StorageTask) -> void:
task.METHODS.DELETE_BUCKET: emit_signal("deleted_bucket", task.data)
elif task.error != null:
emit_signal("error", task.error)
_pooled_tasks.erase(task)
4 changes: 3 additions & 1 deletion addons/supabase/Storage/storage_bucket.gd
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const MIME_TYPES : Dictionary = {
"tiff": "image/tiff",
"tres": "text/plain",
"tscn": "text/plain",
"txt": "text/script",
"txt": "text/plain",
"wav": "audio/wav",
"webm": "video/webm",
"webp": "video/webm",
Expand Down Expand Up @@ -92,6 +92,7 @@ func upload(object : String, file_path : String) -> StorageTask:
var file : File = File.new()
var error : int = file.open(file_path, File.READ)
if error != OK:
printerr("There was an error opening the file at path: ", file_path)
task.complete({})
return task
var header : PoolStringArray = [_header[0] % MIME_TYPES.get(object.get_extension(), "application/octet-stream")]
Expand Down Expand Up @@ -295,6 +296,7 @@ func _on_task_completed(task : StorageTask) -> void:
task.METHODS.DOWNLOAD: emit_signal("downloaded_object", task.data)
elif task.error != null:
emit_signal("error", task.error)
_pooled_tasks.erase(task)

func _clear_raw_request() -> void:
requesting_raw = false
Expand Down
16 changes: 11 additions & 5 deletions addons/supabase/Supabase/supabase.gd
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,17 @@ func _ready() -> void:

# Load all config settings from ProjectSettings
func load_config() -> void:
if ProjectSettings.has_setting(ENVIRONMENT_VARIABLES+"supabaseUrl"):
for key in config.keys():
var setting : String = ProjectSettings.get_setting(ENVIRONMENT_VARIABLES+key)
config[key] = setting if setting!=null and setting!="" else config[key]
else: printerr("No configuration settings found, add them in override.cfg file.")
if config.supabaseKey != "" and config.supabaseUrl != "":
return
for key in config.keys():
if ProjectSettings.has_setting(ENVIRONMENT_VARIABLES+key):
var value : String = ProjectSettings.get_setting(ENVIRONMENT_VARIABLES+key)
if value == "":
printerr("%s has not a valid value." % key)
else:
config[key] = value
else:
printerr("%s key is not defined." % key)
header.append("apikey: %s"%[config.supabaseKey])

func load_nodes() -> void:
Expand Down