File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -41,6 +41,10 @@ import {
4141 migrateV1ToV3 ,
4242 type RateLimitStateV3 ,
4343} from "./storage/migrations.js" ;
44+ import {
45+ getStoragePathState ,
46+ setStoragePathState ,
47+ } from "./storage/path-state.js" ;
4448import {
4549 findProjectRoot ,
4650 getConfigDir ,
@@ -334,31 +338,6 @@ async function ensureGitignore(storagePath: string): Promise<void> {
334338 }
335339}
336340
337- type StoragePathState = {
338- currentStoragePath : string | null ;
339- currentLegacyProjectStoragePath : string | null ;
340- currentLegacyWorktreeStoragePath : string | null ;
341- currentProjectRoot : string | null ;
342- } ;
343-
344- let currentStorageState : StoragePathState = {
345- currentStoragePath : null ,
346- currentLegacyProjectStoragePath : null ,
347- currentLegacyWorktreeStoragePath : null ,
348- currentProjectRoot : null ,
349- } ;
350-
351- const storagePathStateContext = new AsyncLocalStorage < StoragePathState > ( ) ;
352-
353- function getStoragePathState ( ) : StoragePathState {
354- return storagePathStateContext . getStore ( ) ?? currentStorageState ;
355- }
356-
357- function setStoragePathState ( state : StoragePathState ) : void {
358- currentStorageState = state ;
359- storagePathStateContext . enterWith ( state ) ;
360- }
361-
362341export function setStorageBackupEnabled ( enabled : boolean ) : void {
363342 storageBackupEnabled = enabled ;
364343}
Original file line number Diff line number Diff line change 1+ import { AsyncLocalStorage } from "node:async_hooks" ;
2+
3+ export type StoragePathState = {
4+ currentStoragePath : string | null ;
5+ currentLegacyProjectStoragePath : string | null ;
6+ currentLegacyWorktreeStoragePath : string | null ;
7+ currentProjectRoot : string | null ;
8+ } ;
9+
10+ const storagePathStateContext = new AsyncLocalStorage < StoragePathState > ( ) ;
11+
12+ let currentStorageState : StoragePathState = {
13+ currentStoragePath : null ,
14+ currentLegacyProjectStoragePath : null ,
15+ currentLegacyWorktreeStoragePath : null ,
16+ currentProjectRoot : null ,
17+ } ;
18+
19+ export function getStoragePathState ( ) : StoragePathState {
20+ return storagePathStateContext . getStore ( ) ?? currentStorageState ;
21+ }
22+
23+ export function setStoragePathState ( state : StoragePathState ) : void {
24+ currentStorageState = state ;
25+ storagePathStateContext . enterWith ( state ) ;
26+ }
You can’t perform that action at this time.
0 commit comments