MCPcopy Index your code
hub / github.com/docker/docker-agent / ResumeWorkingDir

Method ResumeWorkingDir

cmd/root/backend.go:146–170  ·  view source on GitHub ↗

ResumeWorkingDir looks up the session named by --session and returns the working directory it was created with. It opens (and shares) the same session store CreateSession uses, so this peek does not pay for a second connection. Both explicit IDs and relative refs (e.g. "-1" for the last session) are

(ctx context.Context)

Source from the content-addressed store, hash-verified

144// stored dir, or a dir that no longer exists — returns ok=false and leaves the
145// run to its normal working-directory resolution.
146func (b *localBackend) ResumeWorkingDir(ctx context.Context) (string, bool) {
147 if b.flags.sessionID == "" {
148 return "", false
149 }
150
151 store, err := b.sessionStore(ctx, b.flags.createSessionRequest(""))
152 if err != nil {
153 return "", false
154 }
155
156 // Relative refs (-1, -2, ...) resolve against the shared store here, which
157 // is already open at this point, so they reattach to their worktree too.
158 resolvedID, err := session.ResolveSessionID(ctx, store, b.flags.sessionID)
159 if err != nil {
160 return "", false
161 }
162 sess, err := store.GetSession(ctx, resolvedID)
163 if err != nil || sess.WorkingDir == "" {
164 return "", false
165 }
166 if fi, err := os.Stat(sess.WorkingDir); err != nil || !fi.IsDir() {
167 return "", false
168 }
169 return sess.WorkingDir, true
170}
171
172func (b *localBackend) Close() error {
173 // Ensure any in-progress sessionStore initialization is observed

Callers

nothing calls this directly

Calls 4

sessionStoreMethod · 0.95
ResolveSessionIDFunction · 0.92
createSessionRequestMethod · 0.80
GetSessionMethod · 0.65

Tested by

no test coverage detected