SchumacherFM / wordpress-to-hugo-exporter

Hugo is static site generator written in golang. Wordpress is a tool for remote access to your server ;-) ❗️Contributions welcome!
https://gohugo.io
GNU General Public License v3.0
692 stars 95 forks source link

Windows cannot open zip file correctly. #34

Closed tech4him1 closed 7 years ago

tech4him1 commented 7 years ago

In 7-zip, the path shows up as hugo-export.zip//hugo-export/.... There is an extra no-name directory as the root directory.

tech4him1 commented 7 years ago

Related StackOverflow answer (from CWSpear):

When you put a file in the archive, you can't have absolute files (files starting with a slash) or else it won't open in Windows for some reason.

So got it working not because he (Jesse Bunch, the selected answer at the time of this writing) removed the containing folder but because he removed the starting slash.

I fixed the issue by changing

$zip->addFile($file, $file); // $file is something like /path/to/file.png to

// we make file relative by removing beginning slash so it will open in Windows $zip->addFile($file, ltrim($file, '/')); and then it was able to open in Windows! http://stackoverflow.com/a/11350197

So we should just be able to remove the beginning slash from $local_path for the filename in the zip file. I can test it on Windows and Ubuntu if you want.

SchumacherFM commented 7 years ago

Done! Please download the new source and test it!

tech4him1 commented 7 years ago

Works on Windows 10