Skip to content

Commit

Permalink
Extract to _tmp instead of _scoop_extract to conserve 10 more charact…
Browse files Browse the repository at this point in the history
…ers in path.
  • Loading branch information
lukesampson committed May 29, 2017
1 parent c8405d4 commit 887f041
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions bin/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ echo 'Downloading...'
dl $zipurl $zipfile

'Extracting...'
unzip $zipfile "$dir\_scoop_extract"
cp "$dir\_scoop_extract\scoop-master\*" $dir -r -force
rm "$dir\_scoop_extract" -r -force
unzip $zipfile "$dir\_tmp"
cp "$dir\_tmp\scoop-master\*" $dir -r -force
rm "$dir\_tmp" -r -force
rm $zipfile

echo 'Creating shim...'
Expand Down
16 changes: 8 additions & 8 deletions lib/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -344,23 +344,23 @@ function dl_urls($app, $version, $manifest, $architecture, $dir, $use_cache = $t

if($extract_fn) {
write-host "Extracting... " -nonewline
$null = mkdir "$dir\_scoop_extract"
& $extract_fn "$dir\$fname" "$dir\_scoop_extract"
$null = mkdir "$dir\_tmp"
& $extract_fn "$dir\$fname" "$dir\_tmp"
rm "$dir\$fname"
if ($extract_to) {
$null = mkdir "$dir\$extract_to" -force
}
# fails if zip contains long paths (e.g. atom.json)
#cp "$dir\_scoop_extract\$extract_dir\*" "$dir\$extract_to" -r -force -ea stop
movedir "$dir\_scoop_extract\$extract_dir" "$dir\$extract_to"
#cp "$dir\_tmp\$extract_dir\*" "$dir\$extract_to" -r -force -ea stop
movedir "$dir\_tmp\$extract_dir" "$dir\$extract_to"

if(test-path "$dir\_scoop_extract") { # might have been moved by movedir
if(test-path "$dir\_tmp") { # might have been moved by movedir
try {
rm -r -force "$dir\_scoop_extract" -ea stop
rm -r -force "$dir\_tmp" -ea stop
} catch [system.io.pathtoolongexception] {
cmd /c "rmdir /s /q $dir\_scoop_extract"
cmd /c "rmdir /s /q $dir\_tmp"
} catch [system.unauthorizedaccessexception] {
warn "Couldn't remove $dir\_scoop_extract: unauthorized access."
warn "Couldn't remove $dir\_tmp: unauthorized access."
}
}

Expand Down
16 changes: 8 additions & 8 deletions test/Scoop-Core.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -31,31 +31,31 @@ describe "movedir" {

it "moves directories with no spaces in path" {
$dir = "$working_dir\user"
movedir "$dir\_scoop_extract\$extract_dir" "$dir\$extract_to"
movedir "$dir\_tmp\$extract_dir" "$dir\$extract_to"

"$dir\test.txt" | should contain "this is the one"
"$dir\_scoop_extract\$extract_dir" | should not exist
"$dir\_tmp\$extract_dir" | should not exist
}

it "moves directories with spaces in path" {
$dir = "$working_dir\user with space"
movedir "$dir\_scoop_extract\$extract_dir" "$dir\$extract_to"
movedir "$dir\_tmp\$extract_dir" "$dir\$extract_to"

"$dir\test.txt" | should contain "this is the one"
"$dir\_scoop_extract\$extract_dir" | should not exist
"$dir\_tmp\$extract_dir" | should not exist

# test trailing \ in from dir
movedir "$dir\_scoop_extract\$null" "$dir\another"
movedir "$dir\_tmp\$null" "$dir\another"
"$dir\another\test.txt" | should contain "testing"
"$dir\_scoop_extract" | should not exist
"$dir\_tmp" | should not exist
}

it "moves directories with quotes in path" {
$dir = "$working_dir\user with 'quote"
movedir "$dir\_scoop_extract\$extract_dir" "$dir\$extract_to"
movedir "$dir\_tmp\$extract_dir" "$dir\$extract_to"

"$dir\test.txt" | should contain "this is the one"
"$dir\_scoop_extract\$extract_dir" | should not exist
"$dir\_tmp\$extract_dir" | should not exist
}
}

Expand Down
File renamed without changes.

0 comments on commit 887f041

Please sign in to comment.