Skip to content

Commit

Permalink
feat: ⚡ improve and copy LoadNative's cache check over to Resolve-Cac…
Browse files Browse the repository at this point in the history
…hedPackage (#49)
  • Loading branch information
anonhostpi committed Jan 19, 2024
1 parent 34b663e commit 8f112d6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Import-Package/packaging.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,10 @@ public static extern IntPtr dlopen(string path, int flags);
}
Write-Verbose "Loading native dll from path '$CopyTo' (copying from '$Path')."
$end_path = "$CopyTo\$($Path | Split-Path -Leaf)"
If( -not (Test-Path $end_path -PathType Leaf) ){
Copy-Item $Path $CopyTo -Force -ErrorAction SilentlyContinue | Out-Null
} Else {
If( Test-Path $end_path -PathType Leaf ){
Write-Verbose "$CopyTo is already present and loaded. Native dll not copied - This could cause version conflicts"
} Else {
Copy-Item $Path $CopyTo -Force -ErrorAction SilentlyContinue | Out-Null
}
$Path = $end_path
} Else {
Expand Down
9 changes: 9 additions & 0 deletions Import-Package/src/Resolve-CachedPackage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,15 @@ function Resolve-CachedPackage {
If( Test-Path $this_natives_path ){
Write-Verbose "[Import-Package:Preparation] Native files for $( $Options.Name ) $( $Options.Version ) will be copied from cache now:"
Write-Verbose "- Folder: $this_natives_path"
Resolve-Path (Join-Path $this_natives_path "*") -ErrorAction SilentlyContinue | ForEach-Object {
$native = $_
$native_name = $_ | Split-Path -Leaf
If( Test-Path (Join-Path $base_natives_path $native_name) ){
Write-Verbose "$native_name is already present and loaded. Native dll not copied - This could cause version conflicts"
} Else {
Copy-Item $native $base_natives_path -Force -ErrorAction SilentlyContinue | Out-Null
}
}
} Else {
Write-Verbose "[Import-Package:Preparation] Any native files for $( $Options.Name ) $( $Options.Version ) will be copied from source at load time:"
Write-Verbose "- Folder: $( $Options.Source )"
Expand Down

0 comments on commit 8f112d6

Please sign in to comment.