0 votes

Hello, I'm creating an updater for my game but when I try to read the ZIP file using the class ZIPReader it just returns Error.Failed.

Here's the segment of the code that fails:

const string downloadPath = "user://update.zip";
FileAccess file = FileAccess.Open(downloadPath, FileAccess.ModeFlags.Write);
file.StoreBuffer(body);

GD.Print("Download completed!");

ZIPReader zip = new ZIPReader();
Error openProcess = zip.Open(downloadPath);

if (openProcess != Error.Ok)
{
    GD.PrintErr("Can't open the 'update.zip' file!");
    GD.PrintErr($"{openProcess.ToString()}");
    goto install_failed;
}

I've tried to open the downloaded zip file outside the app and I can open it correctly.

Godot version v4.0.beta9.mono.official [e780dc332]
in Engine by (64 points)
retagged by

1 Answer

0 votes
Best answer

Well, I've fixed this by calling Flush after storing the buffer in the file.

FileAccess file = FileAccess.Open(path, FileAccess.ModeFlags.Write);
file.StoreBuffer(buffer);
file.Flush();

This may be a bug (There's an issue already https://github.com/godotengine/godot/issues/68614) so maybe doing this isn't necessary in future builds.

by (64 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.