Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions cmd/pipe/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,11 @@
isName = true
}

// An explicit `pipe -get` must always fetch fresh — drop any stale
// disk cache for this URL (see object.InvalidateModuleCache; the
// cache is otherwise never invalidated).
object.InvalidateModuleCache(target)

modDir := object.ModuleCacheDir()
_, content, err := object.ResolveImport(target)
if err != nil {
Expand Down Expand Up @@ -648,7 +653,7 @@
func runMCPWatchdog(pgidArg string) {
_, _ = io.Copy(io.Discard, os.Stdin)
if pgid, err := strconv.Atoi(pgidArg); err == nil {
_ = syscall.Kill(-pgid, syscall.SIGKILL)

Check failure on line 656 in cmd/pipe/main.go

View workflow job for this annotation

GitHub Actions / Byte-identity (windows-latest)

undefined: syscall.Kill
}
os.Exit(0)
}
Expand Down
12 changes: 12 additions & 0 deletions pkg/object/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,18 @@ func fetchURLModule(url string) (string, string, error) {
return url, resp, nil
}

// InvalidateModuleCache removes the disk-cached copy of a module URL, so a
// subsequent ResolveImport/fetchURLModule re-downloads it. Used by `pipe -get`
// for an always-fresh explicit fetch — without this, `pipe -get <name>` served
// a stale module forever (the cache was only ever written, never invalidated,
// live-observed when a freshly published sqlite v0.8.6 still resolved to the
// old pre-ALTER copy). Runtime imports deliberately keep the cache to avoid a
// network hit on every program run.
func InvalidateModuleCache(url string) {
cachePath := filepath.Join(moduleCacheDir, urlToCacheKey(url))
os.Remove(cachePath)
}

func urlToCacheKey(url string) string {
// Convert URL to a safe filename: replace special chars
url = strings.ReplaceAll(url, "https://", "")
Expand Down
Loading