Repository: mne-tools/mne-python

Issue:
RuntimeError: Zip file did not have correct names` when downloading fsaverage on windows
I get `RuntimeError: Zip file did not have correct names` when downloading fsaverage files on Windows machine:
```python
from mne.datasets import fetch_fsaverage
fs_dir = fetch_fsaverage(verbose=True)
```

```python-traceback
179 files missing from c:\src\mne-python\mne\datasets\_fsaverage\root.txt in C:\Users\mmagn\mne_data\MNE-fsaverage-data
Downloading missing files remotely
Downloading https://files.osf.io/v1/resources/rxvq7/providers/osfstorage/5cbdba4ef2be3c0019091890?action=download&version=2&direct&revision=2 (186.7 MB)
[........................................] 100.00% (186.7 MB,  25.5 MB/s) \   
Verifying hash 5133fe92b7b8f03ae19219d5f46e4177.
File saved as C:\Users\mmagn\AppData\Local\Temp\tmpof0geus7\temp.zip.

Extracting missing files
Traceback (most recent call last):

  File "<ipython-input-47-9a322ebca572>", line 2, in <module>
    fs_dir = fetch_fsaverage(verbose=True)

  File "<c:\src\mne-python\mne\externals\decorator.py:decorator-gen-331>", line 2, in fetch_fsaverage

  File "c:\src\mne-python\mne\utils\_logging.py", line 88, in wrapper
    return function(*args, **kwargs)

  File "c:\src\mne-python\mne\datasets\_fsaverage\base.py", line 92, in fetch_fsaverage
    hash_=data['hash_'],

  File "c:\src\mne-python\mne\datasets\utils.py", line 798, in _manifest_check_download
    '\n%s' % ('\n'.join(missing)))

RuntimeError: Zip file did not have correct names:
fsaverage/
fsaverage/bem/
fsaverage/label/
fsaverage/mri.2mm/
fsaverage/mri/
fsaverage/mri/orig/
fsaverage/mri/transforms/
fsaverage/mri/transforms/bak/
fsaverage/scripts/
fsaverage/src/
fsaverage/stats/
fsaverage/surf/
fsaverage/tmp/
fsaverage/touch/
fsaverage/trash/
```


Discussion:
Can you change line 794 to say `if not f.endswith('/')` instead of `if not f.endswithe(op.sep)` and see if it fixes it? I think I made a faulty assumption about how ~~`members`~~ `namelist` would work on Windows.

Resolving patch:
diff --git a/mne/datasets/utils.py b/mne/datasets/utils.py
--- a/mne/datasets/utils.py
+++ b/mne/datasets/utils.py
@@ -790,8 +790,7 @@ def _manifest_check_download(manifest_path, destination, url, hash_):
             _fetch_file(url, fname_path, hash_=hash_)
             logger.info('Extracting missing file%s' % (_pl(need),))
             with zipfile.ZipFile(fname_path, 'r') as ff:
-                members = set(f for f in ff.namelist()
-                              if not f.endswith(op.sep))
+                members = set(f for f in ff.namelist() if not f.endswith('/'))
                 missing = sorted(members.symmetric_difference(set(names)))
                 if len(missing):
                     raise RuntimeError('Zip file did not have correct names:'


Test patch:
diff --git a/mne/datasets/tests/test_datasets.py b/mne/datasets/tests/test_datasets.py
--- a/mne/datasets/tests/test_datasets.py
+++ b/mne/datasets/tests/test_datasets.py
@@ -100,10 +100,13 @@ def test_fetch_parcellations(tmpdir):
 
 def _fake_zip_fetch(url, fname, hash_):
     with zipfile.ZipFile(fname, 'w') as zipf:
+        with zipf.open('foo/', 'w'):
+            pass
         for fname in _zip_fnames:
             with zipf.open(fname, 'w'):
                 pass
 
+
 @pytest.mark.skipif(sys.version_info < (3, 6),
                     reason="writing zip files requires python3.6 or higher")
 @pytest.mark.parametrize('n_have', range(len(_zip_fnames)))