Расширения для VS Code не работают при загрузке с помощью wget или curl - PullRequest
0 голосов
/ 06 февраля 2020

На удаленной машине я пытаюсь использовать wget для загрузки расширений для VS Code. Однако загруженные файлы всегда повреждены и не могут быть использованы. Оказывается, что использование wget или curl приведет к получению файлов, которые немного меньше, чем при использовании браузера, поэтому представляется разумным, что их нельзя разархивировать. URL-адрес, который я использовал для загрузки: https://marketplace.visualstudio.com/_apis/public/gallery/publishers/stkb/vsextensions/rewrap/1.9.1/vspackage

Downloads/tmp >ls -la
total 168
drwxrwxrwx 1 enno enno  4096 Feb  6 08:45 .
drwxrwxrwx 1 enno enno  4096 Feb  6 08:45 ..
-rwxrwxrwx 1 enno enno 85317 Feb  6 08:45 curl.vsix
-rwxrwxrwx 1 enno enno 85317 Feb  6 08:45 wget.vsix
BWP-181WD4:Downloads/tmp >unzip curl.vsix
Archive:  curl.vsix
  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
note:  curl.vsix may be a plain executable, not an archive
unzip:  cannot find zipfile directory in one of curl.vsix or
        curl.vsix.zip, and cannot find curl.vsix.ZIP, period.

Downloads/tmp >unzip wget.vsix
Archive:  wget.vsix
  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
note:  wget.vsix may be a plain executable, not an archive
unzip:  cannot find zipfile directory in one of wget.vsix or
        wget.vsix.zip, and cannot find wget.vsix.ZIP, period.

Тем не менее, использование загруженного браузером файла прекрасно работает:

BWP-181WD4:Downloads/tmp >unzip ./browser.vsix
Archive:  ./browser.vsix
  inflating: extension.vsixmanifest
  inflating: [Content_Types].xml
  inflating: extension/CHANGELOG.md
  inflating: extension/images/logo.png
  inflating: extension/images/logo.svg
  inflating: extension/package.json
  inflating: extension/README.md
...

Почему? Размеры файлов явно различаются:

Downloads/tmp >ls -la
total 256
drwxrwxrwx 1 enno enno  4096 Feb  6 08:52 .
drwxrwxrwx 1 enno enno  4096 Feb  6 08:50 ..
-rwxrwxrwx 1 enno enno 90035 Feb  6 08:49 browser.vsix
-rwxrwxrwx 1 enno enno 85317 Feb  6 08:45 curl.vsix
-rwxrwxrwx 1 enno enno 85317 Feb  6 08:45 wget.vsix

Это связано с тем, как wget и curl извлекают файлы или как Microsoft обслуживает эти файлы?

1 Ответ

2 голосов
/ 06 февраля 2020

Файлы, загруженные с помощью wget и curl: gzip files.

Измените имя файла на vspackage.gz и используйте gunzip для извлечения файла vsix

Если вы просматриваете заголовок ответа в браузере и видите, что он сжат gzip.

Найдите способ для curl / wget использовать content-disposition и content-encoding заголовка ответа.

...