@@ -2,7 +2,7 @@ import { BusEvent } from "@/bus/bus-event"
22import { InstanceState } from "@/effect/instance-state"
33import { makeRuntime } from "@/effect/run-service"
44import { Git } from "@/git"
5- import { Effect , Fiber , Layer , Scope , ServiceMap } from "effect"
5+ import { Effect , Layer , ServiceMap } from "effect"
66import { formatPatch , structuredPatch } from "diff"
77import fs from "fs"
88import fuzzysort from "fuzzysort"
@@ -323,7 +323,6 @@ export namespace File {
323323
324324 interface State {
325325 cache : Entry
326- fiber : Fiber . Fiber < void > | undefined
327326 }
328327
329328 export interface Interface {
@@ -348,7 +347,6 @@ export namespace File {
348347 Effect . fn ( "File.state" ) ( ( ) =>
349348 Effect . succeed ( {
350349 cache : { files : [ ] , dirs : [ ] } as Entry ,
351- fiber : undefined as Fiber . Fiber < void > | undefined ,
352350 } ) ,
353351 ) ,
354352 )
@@ -406,21 +404,15 @@ export namespace File {
406404 s . cache = next
407405 } )
408406
409- const scope = yield * Scope . Scope
407+ let cachedScan = yield * Effect . cached (
408+ scan ( ) . pipe ( Effect . catchCause ( ( ) => Effect . void ) ) ,
409+ )
410410
411411 const ensure = Effect . fn ( "File.ensure" ) ( function * ( ) {
412- const s = yield * InstanceState . get ( state )
413- if ( ! s . fiber )
414- s . fiber = yield * scan ( ) . pipe (
415- Effect . catchCause ( ( ) => Effect . void ) ,
416- Effect . ensuring (
417- Effect . sync ( ( ) => {
418- s . fiber = undefined
419- } ) ,
420- ) ,
421- Effect . forkIn ( scope ) ,
422- )
423- yield * Fiber . join ( s . fiber )
412+ yield * cachedScan
413+ cachedScan = yield * Effect . cached (
414+ scan ( ) . pipe ( Effect . catchCause ( ( ) => Effect . void ) ) ,
415+ )
424416 } )
425417
426418 const init = Effect . fn ( "File.init" ) ( function * ( ) {
0 commit comments