szimek / sharedrop

Easy P2P file transfer powered by WebRTC - inspired by Apple AirDrop
https://www.sharedrop.io
MIT License
9.94k stars 725 forks source link

Every file comes as empty ZIP #117

Open dhlavaty opened 3 years ago

dhlavaty commented 3 years ago

I'm not able to send any file using Sharedrop.

Every file (sigle file or multiple files also) is sent as a ZIP (not sure why, it worked without any problem last time I used it). And the ZIP file is empty. It has exactly 22 Bytes.

szimek commented 3 years ago

Hi! You're the second person who reported this issue recently, however I can't reproduce it myself.

What devices are you using? What browsers (including their version) are you using on both devices?

dhlavaty commented 3 years ago

Machine 1: Macbook Pro (Intel) - macOS Catalina v10.15.7 Firefox 88.0.1 or Chrome 90.0.4430.212

Machine 2: Macbook Pro (Intel) - macOS Big Sur v11.3.1 Firefox 88.0.1 or Chrome 90.0.4430.212

Connected on local network via WIFI. And any combination of mentioned browsers causes same issue.

szimek commented 3 years ago

Does it also happen if you open 2 tabs on the same device and send a single file between them?

dhlavaty commented 3 years ago

Yes, it does.

szimek commented 3 years ago

Thanks. Unfortunately, I can't replicate this bug.

Is there any chance you could try to debug it? There's a file /sharedrop/components/peer-widget.js and there's _reduceFiles function that has the following check:

async _reduceFiles(files) {
  ...

  if (files.length === 1) {
    return Promise.resolve(files[0]);
  }

  ...
}

Something must be wrong here - for some reason this check fails and even though you send just one file it tries to bundle them together in a zip file. That's just my guess.

dhlavaty commented 3 years ago

I've just checked my another PC at home, with same result.

Machine 3: desktop PC (Intel i5) - Windows 10 Home 19042.985 Firefox 88.0.1

Connected on same local network via WIFI.

I'll try to look at it more deeply this weekend.

dhlavaty commented 3 years ago

Hi, some of my observations about this bug:

  1. Bug is somehow related with drag&drop. I was not able to replicate it by "standard" open file dialog.
  2. When I drag&drop files from Mac's Finder - everything works ok.
  3. When I drag&drop files from Visual Studio Code or Commander One - (single or multiple files) - they are always 22 Byte ZIP files
  4. Sending (drag&drop) dot files (by default hidden in Mac Finder, so you have to unhide them), will sometimes just freeze, and when it works, it will remove the leading dot from file name. It is undeterministic.

All mention above I've tried on both my Mac machines and both browsers mentioned in my previous posts.

szimek commented 3 years ago

Thank you! I was finally able to replicate this issue. I've never tried to drop a file from an app other than Finder on Mac ;)

Here's what I found: when you drop a file from e.g. VSCode, the files list is empty. This check

if (files.length === 1) {
  // send one file
} else {
  // send zipped files
}

fails, because files.length is 0, so it tries to zip an empty file list 🤦 .

I'll have to check if there's a way to properly handle drag & drop in such cases.