From 9d0abe36841122af1c7d08334c2152a7b885b588 Mon Sep 17 00:00:00 2001 From: Christopher Williams Date: Fri, 18 Nov 2016 10:31:39 -0500 Subject: [PATCH 1/2] Fix #169 - Files with very long paths fail to extract on Windows - Use robocopy instead of xcopy, alter to smooth out exit codes of 0-3 to become 0 Signed-off-by: Christopher Williams --- libraries/sevenzip_command_builder.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/sevenzip_command_builder.rb b/libraries/sevenzip_command_builder.rb index 8d8a9934..26fd4bc8 100644 --- a/libraries/sevenzip_command_builder.rb +++ b/libraries/sevenzip_command_builder.rb @@ -40,7 +40,7 @@ def sevenzip_command currdir += "\\%#{count}" end - cmd += "#{ENV.fetch('SystemRoot')}\\System32\\xcopy \"#{currdir}\" \"#{resource.home_dir}\" /s /e" + cmd += "(#{ENV.fetch('SystemRoot')}\\System32\\robocopy \"#{currdir}\" \"#{resource.home_dir}\" /s /e) ^& IF %ERRORLEVEL% LEQ 3 cmd /c exit 0" end def sevenzip_binary From 755230598a12d374b607adb37d675087a4e58389 Mon Sep 17 00:00:00 2001 From: Christopher Williams Date: Fri, 18 Nov 2016 14:10:48 -0500 Subject: [PATCH 2/2] Fix 7-zip extraction with long paths when strip_components is >= 1 Signed-off-by: Christopher Williams --- libraries/sevenzip_command_builder.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/sevenzip_command_builder.rb b/libraries/sevenzip_command_builder.rb index 26fd4bc8..6fdda93e 100644 --- a/libraries/sevenzip_command_builder.rb +++ b/libraries/sevenzip_command_builder.rb @@ -29,11 +29,11 @@ def sevenzip_command return sevenzip_command_builder(resource.path, 'x') end - tmpdir = make_temp_directory + tmpdir = make_temp_directory.tr('/', '\\') cmd = sevenzip_command_builder(tmpdir, 'e') cmd += ' && ' - currdir = tmpdir.tr('/', '\\') + currdir = tmpdir 1.upto(resource.strip_components).each do |count| cmd += "for /f %#{count} in ('dir /ad /b \"#{currdir}\"') do "