Skip to content

Conversation

@cpAdm
Copy link
Contributor

@cpAdm cpAdm commented Oct 17, 2025

Detection of zip files with just mime type is not quite enough, use filename instead to get mimetype. Moved this logic into processTraceFiles. Here we now select the first valid ZIP file. If none found, send to sw anyway, and show error message later.

Also removed unused state uploadedTraceName.

Fixes: #37906

return;
const file = files.item(0)!;

// Do best effort to select the first valid trace valid, if not, rely on error reporting of sw
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pasting multiple files looks like a user error, we can bail sooner or leave it as is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It definitely is a user error. However, why not try to find/load the valid trace file from this fileslist? I think that's preferable over not showing anything.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this regresses users that renamed their traces to foo.trace, what do we do to those?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point.
However, in this case we just try to find the first .zip file, if not found it will just pick the first one and send it to the server to handle (possibly returning an error). So, processing will just work fine for them. It is just that those users don't 'benefit' from this 'best effort'

if (!e.clipboardData?.files.length)
return;
for (const file of e.clipboardData.files) {
if (file.type !== 'application/zip')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd just add application/x-zip-compressed for old Windows systems.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not just for old windows systems, I am experiencing this mime-type behaviour on Windows 11.
But then, there are probably other cases we need to consider depending on browser/operating system (https://mime-type.com/file-extension/zip/). So checking file extension seems easiest and most reliable here?

@pavelfeldman
Copy link
Member

For potentially breaking changes, we should definitely start with an issue

@cpAdm
Copy link
Contributor Author

cpAdm commented Oct 20, 2025

@pavelfeldman This PR already references to existing issue: #37906.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Not all zip files can be pasted into trace viewer

2 participants