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

[Lua] Failed Extract leaves open file handle #31

Open
DerfJagged opened this issue Aug 5, 2024 · 5 comments
Open

[Lua] Failed Extract leaves open file handle #31

DerfJagged opened this issue Aug 5, 2024 · 5 comments
Labels

Comments

@DerfJagged
Copy link
Contributor

DerfJagged commented Aug 5, 2024

It looks like there might be a bug in Aurora's Lua for zip handling.

If I have an invalid zip at PATH_TO_ZIP and run this:

local zip = ZipFile.OpenFile(PATH_TO_ZIP);
if zip == nil then
	Script.ShowMessageBox("ERROR", "Failed to open zip!", "OK");
	return false;
end
local result = zip.Extract(zip, downloadsPath.."tmp\\");
FileSystem.DeleteFile(http.OutputPath);
if result == false then
	Script.ShowMessageBox("ERROR", "Extraction failed!", "OK");
else
	-- Do stuff
end

Then it will fail the zip.Extract and show the "Extraction failed!" error, as you'd expect.
However, it seems to keep an open file handle on the zip file, and the FileSystem.DeleteFile command fails, and you can't even manually delete the file via FTP until you reboot Aurora. I don't see any script developer accessible ZipFile.CloseFile command, so I think Aurora source needs to be adjusted to close the file upon Extract failure.

The log shows this message:
{ "time" : "17:32:28.500", "thread" : "0xF9000004", "type" : "normal", "filter" : "RecursiveDeleteDirectory", "message" : "Failed to delete file: Game:\User\Scripts\Utility\HomebrewStore\Downloads\tmp.7z. Error Code: 32" }


For a practical example, I had a typo on a link in the Homebrew Store and it caused that download to fail, but since it kept an open file handle, it would not allow any subsequent downloads to extract since they were trying to write to the same place.

If you want to test it, I've made an item called "DO NOT DOWNLOAD" at the very bottom of the "Other" section of the homebrew store which will trigger this bug.

@Swizzy
Copy link
Contributor

Swizzy commented Aug 6, 2024

We'll look into it - thanks for letting us know

@Ste1io
Copy link
Contributor

Ste1io commented Aug 22, 2024

Is this related to your comment in your script source about large files not extracting as well @DerfJagged ? Noticed it last week and had it on my agenda to look into this week anyways.

@DerfJagged
Copy link
Contributor Author

DerfJagged commented Aug 24, 2024

Is this related to your comment in your script source about large files not extracting as well @DerfJagged ? Noticed it last week and had it on my agenda to look into this week anyways.

It's two separate issues:

  1. Large (>350MB) zip files fail to extract
  2. If it fails to unzip a file (e.g. if it's not a 7z file) it will keep an open handle on that file. Not sure if failing to extract a large file will keep an open handle or not.

@Ste1io
Copy link
Contributor

Ste1io commented Aug 26, 2024

@DerfJagged you mention an "invalid zip file" in your original message, but both your last message (and the log error entry you originally shared) reference a 7z archive. Could you clarify what type of archive you were encountered this with, and if possible attach that dummy archive that is known to cause this so I can repro it?

I looked for the "DO NOT DOWNLOAD" item in the Homebrew Store directory, but didn't see it in either of your last two commits.

Thanks for your help.

@Ste1io Ste1io added the bug label Aug 27, 2024
@DerfJagged
Copy link
Contributor Author

@Ste1io When you use the http command to download files, you specify the file extension it will be saved as, so it will successfully download it and it will always be named as .7z, which is why the log entry mentions tmp.7z.

local http = Http.Get("https://example.com/file.xyz", "Downloads\tmp.7z");

I ran into it because I had linked https://consolemods.org/wiki/File:XellLaunch.7z which is the file's description page, not the actual link for the download (which would be https://consolemods.org/wiki/images/4/41/XellLaunch.7z). This caused it to just download the http page, and save it as tmp.7z. It'd probably also be reproducible if someone just renamed a .zip file to .7z.

The "DO NOT DOWNLOAD" option is on the actual homebrew store. Run the script on your Xbox, go to the "ConsoleMods - Other" directory, and it's the last item. It will download, fail to extract, and that tmp.7z file will still be held open which breaks any further downloads until you restart Aurora.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants