|
@@ -36,6 +36,9 @@ class Download:
|
|
|
func _init() -> void:
|
|
|
set_process(false)
|
|
|
connect("request_completed", self, "_on_request_completed")
|
|
|
+
|
|
|
+func _ready():
|
|
|
+ connect("stats_updated", Messenger, "_on_statusUpdate")
|
|
|
|
|
|
func get_stats() -> Download:
|
|
|
return currentDownload
|
|
@@ -74,9 +77,8 @@ func _process(delta):
|
|
|
func _download():
|
|
|
ensureFolder(currentDownload._kind)
|
|
|
download_file = currentDownload._file_name
|
|
|
- .connect("stats_updated", Messenger, "_on_statusUpdate")
|
|
|
_send_head_request()
|
|
|
- print("downloading %s" %currentDownload._file_name)
|
|
|
+ print("downloading %s" %currentDownload._current_url)
|
|
|
downloading = true
|
|
|
|
|
|
func ensureFolder(kind):
|
|
@@ -99,7 +101,7 @@ func download(file, kind):
|
|
|
download._file_name = "user://%s/%s"%[kind, file]
|
|
|
download._current_url = make_filename(kind, file)
|
|
|
download._kind = kind
|
|
|
- downloads[kind][file] = download
|
|
|
+ downloads[kind][download._file_name] = download
|
|
|
|
|
|
func make_filename(kind, file):
|
|
|
return kinds[kind]%file
|
|
@@ -139,8 +141,11 @@ func _on_request_completed(p_result,
|
|
|
_send_get_request()
|
|
|
|
|
|
elif _last_method == HTTPClient.METHOD_GET:
|
|
|
+ print("file download complete %s"%currentDownload._current_url)
|
|
|
+ _file.close()
|
|
|
emit_signal("file_downloaded", currentDownload)
|
|
|
Messenger._on_file_downloaded(currentDownload)
|
|
|
+ downloading = false
|
|
|
downloads[currentDownload._kind].erase(currentDownload._file_name)
|
|
|
if len(downloads[currentDownload._kind]) == 0:
|
|
|
downloads.erase(currentDownload._kind)
|