sourcify
sourcify copied to clipboard
Upload from Windows machines can not be processed properly
This is an issue that keeps coming back. On the sourcify frontend, if we upload a json file or zip file from Windows machines, it will complain "Metadata files missing". If we upload the same file from Mac, everything works fine. If we use API to upload a file, the bug will not be triggered. However if we upload a zip file with a directory structure from Windows, the API will complain can not find the file after we select the contract.
Is it exactly the same file or a Windows formatted file? Can you maybe share them?
I will get my hands on a Windows machine next week and will update you.
correct. The file is the same. The only difference is uploading from Windows 11 (chrome/edge) vs MacOS (Safari).
contracts.zip
I was able to pin down the issue to a problem with the zip library adm-zip
we are using.
On the Windows machine, when reading the header at zipFile.js
line 50, the mainHeader.offset
returns an unusually large index in comparison to Unix machines (71041024
vs 1084
for this repo as zip)
This can have something to do with the Windows style line ends: https://stackoverflow.com/a/3831473/6528944
Will look further but it seems we might need to change the zip library we are using, hoping it will resolve the issue. Also while on it, there's no need to write the files and read them back. We can do all of these in-memory.
Is the zipFile.js running in the frontend or backend? If we upload a zip file with directory structures through the API, the same issue will happen, although zip file without directory structure works for API
It is running on the backend. That's good and interesting info and I'll add that in the bug report. But we'll likely replace adm-zip
completely. Thanks.
The issue seems to persist on the jszip library as well. Similarly the error is on reading directories at https://github.com/Stuk/jszip/blob/eaacc682fad834b1e280b58a728704b216c74510/lib/zipEntries.js#L156 not reading files. What really weird is I can't find any issues on Windows machines related to this, which I presume should be prevalent.
one more piece of information that maybe useful. The contents of the zip file were created on a Linux vm instead of windows.
Turns out the issue was simpler. Windows was sending a different MIME type we were not checking https://github.com/ethereum/sourcify/commit/92d864d5a3ea1b35ebe29bbf83b5f9cdbe92fbaf
It's released, can you please check?
Yes all good now