MCPcopy Create free account
hub / github.com/microsoft/typescript-go / handleRelease

Method handleRelease

internal/api/session.go:974–993  ·  view source on GitHub ↗

handleRelease decrements the ref count for a snapshot. The snapshot and its registries are only cleaned up when the ref count reaches zero.

(ctx context.Context, params *ReleaseParams)

Source from the content-addressed store, hash-verified

972// handleRelease decrements the ref count for a snapshot.
973// The snapshot and its registries are only cleaned up when the ref count reaches zero.
974func (s *Session) handleRelease(ctx context.Context, params *ReleaseParams) (any, error) {
975 if params == nil || params.Snapshot == 0 {
976 return nil, fmt.Errorf("%w: empty handle", ErrClientError)
977 }
978
979 s.snapshotsMu.Lock()
980 sd := s.snapshots[params.Snapshot]
981 if sd == nil {
982 s.snapshotsMu.Unlock()
983 return nil, fmt.Errorf("%w: snapshot %d not found", ErrClientError, params.Snapshot)
984 }
985 sd.refCount--
986 if sd.refCount <= 0 {
987 delete(s.snapshots, params.Snapshot)
988 // Release the API session's ref on the project snapshot.
989 sd.snapshot.Deref(s.projectSession)
990 }
991 s.snapshotsMu.Unlock()
992 return true, nil
993}
994
995// handleGetDefaultProjectForFile returns the default project for a given file,
996// or nil if no project currently contains the file.

Callers 1

HandleRequestMethod · 0.95

Calls 4

ErrorfMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45
DerefMethod · 0.45

Tested by

no test coverage detected