Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(windows+ollama): create download directory before downloading #900

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 19 additions & 20 deletions ollama/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,38 @@ $pkg_src_bin = "$Env:USERPROFILE\.local\opt\ollama-v$Env:WEBI_VERSION"
$pkg_src_dir = "$Env:USERPROFILE\.local\opt\ollama-v$Env:WEBI_VERSION"
$pkg_src = "$pkg_src_dir"

New-Item "$Env:USERPROFILE\Downloads\webi" -ItemType Directory -Force | Out-Null
$pkg_download = "$Env:USERPROFILE\Downloads\webi\ollama\$Env:WEBI_VERSION\$Env:WEBI_PKG_FILE"
$pkg_download_dir = "$Env:USERPROFILE\Downloads\webi\$pkg_cmd_name\$Env:WEBI_VERSION"
$pkg_download_file = "$pkg_download_dir\$Env:WEBI_PKG_FILE"

# Fetch archive
IF (!(Test-Path -Path "$pkg_download")) {
Write-Output " Downloading ollama v$Env:WEBI_VERSION from $Env:WEBI_PKG_URL to $pkg_download"
& curl.exe -A "$Env:WEBI_UA" -fsSL "$Env:WEBI_PKG_URL" -o "$pkg_download.part"
& Move-Item "$pkg_download.part" "$pkg_download"
IF (!(Test-Path -Path "$pkg_download_file")) {
New-Item "$pkg_download_dir" -ItemType Directory -Force | Out-Null
Write-Output " Downloading $pkg_cmd_name v$Env:WEBI_VERSION from $Env:WEBI_PKG_URL to $pkg_download_file"
& curl.exe -A "$Env:WEBI_UA" -fsSL "$Env:WEBI_PKG_URL" -o "$pkg_download_file.part"
& Move-Item "$pkg_download_file.part" "$pkg_download_file"
}

IF (!(Test-Path -Path "$pkg_src_dir")) {
IF (!(Test-Path -Path "$pkg_src_cmd")) {
Write-Output " Installing ollama v$Env:WEBI_VERSION"

Push-Location .local\tmp

# Remove any leftover tmp cruft
Remove-Item -Path ".\ollama*" -Recurse -ErrorAction Ignore
# Remove any leftover tmp cruft, recreate location, push into it
Remove-Item -Path ".local\tmp\ollama-v$Env:WEBI_VERSION" -Recurse -ErrorAction Ignore
New-Item ".local\tmp\ollama-v$Env:WEBI_VERSION" -ItemType Directory -Force | Out-Null
Push-Location ".\.local\tmp\"

# Unpack archive file into this temporary directory
New-Item "ollama-v$Env:WEBI_VERSION" -ItemType Directory -Force | Out-Null
Push-Location "ollama-v$Env:WEBI_VERSION"

Push-Location ".\ollama-v$Env:WEBI_VERSION\"
# Windows BSD-tar handles zip. Imagine that.
Write-Output "Unpacking $pkg_download"
& tar xf "$pkg_download"

Write-Output " Unpacking $pkg_download_file"
& tar xf "$pkg_download_file"
Pop-Location

# Settle unpacked archive into place
Write-Output "Install Location: $pkg_src_cmd"
Move-Item -Path ".\ollama*" -Destination "$pkg_src_dir"
Write-Output " Install Location: $pkg_src_cmd"
Move-Item -Path ".\ollama-v$Env:WEBI_VERSION" -Destination "$pkg_src_dir"

# Exit tmp
# Remove any leftover tmp cruft & exit tmp
Remove-Item -Path ".local\tmp\ollama-v$Env:WEBI_VERSION" -Recurse -ErrorAction Ignore
Pop-Location
}

Expand Down
Loading