|
@@ -2,7 +2,7 @@ import { BusEvent } from "@/bus/bus-event"
|
|
|
import { InstanceState } from "@/effect/instance-state"
|
|
import { InstanceState } from "@/effect/instance-state"
|
|
|
import { makeRuntime } from "@/effect/run-service"
|
|
import { makeRuntime } from "@/effect/run-service"
|
|
|
import { Git } from "@/git"
|
|
import { Git } from "@/git"
|
|
|
-import { Effect, Fiber, Layer, Scope, ServiceMap } from "effect"
|
|
|
|
|
|
|
+import { Effect, Layer, ServiceMap } from "effect"
|
|
|
import { formatPatch, structuredPatch } from "diff"
|
|
import { formatPatch, structuredPatch } from "diff"
|
|
|
import fs from "fs"
|
|
import fs from "fs"
|
|
|
import fuzzysort from "fuzzysort"
|
|
import fuzzysort from "fuzzysort"
|
|
@@ -323,7 +323,6 @@ export namespace File {
|
|
|
|
|
|
|
|
interface State {
|
|
interface State {
|
|
|
cache: Entry
|
|
cache: Entry
|
|
|
- fiber: Fiber.Fiber<void> | undefined
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export interface Interface {
|
|
export interface Interface {
|
|
@@ -348,7 +347,6 @@ export namespace File {
|
|
|
Effect.fn("File.state")(() =>
|
|
Effect.fn("File.state")(() =>
|
|
|
Effect.succeed({
|
|
Effect.succeed({
|
|
|
cache: { files: [], dirs: [] } as Entry,
|
|
cache: { files: [], dirs: [] } as Entry,
|
|
|
- fiber: undefined as Fiber.Fiber<void> | undefined,
|
|
|
|
|
}),
|
|
}),
|
|
|
),
|
|
),
|
|
|
)
|
|
)
|
|
@@ -406,21 +404,15 @@ export namespace File {
|
|
|
s.cache = next
|
|
s.cache = next
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- const scope = yield* Scope.Scope
|
|
|
|
|
|
|
+ let cachedScan = yield* Effect.cached(
|
|
|
|
|
+ scan().pipe(Effect.catchCause(() => Effect.void)),
|
|
|
|
|
+ )
|
|
|
|
|
|
|
|
const ensure = Effect.fn("File.ensure")(function* () {
|
|
const ensure = Effect.fn("File.ensure")(function* () {
|
|
|
- const s = yield* InstanceState.get(state)
|
|
|
|
|
- if (!s.fiber)
|
|
|
|
|
- s.fiber = yield* scan().pipe(
|
|
|
|
|
- Effect.catchCause(() => Effect.void),
|
|
|
|
|
- Effect.ensuring(
|
|
|
|
|
- Effect.sync(() => {
|
|
|
|
|
- s.fiber = undefined
|
|
|
|
|
- }),
|
|
|
|
|
- ),
|
|
|
|
|
- Effect.forkIn(scope),
|
|
|
|
|
- )
|
|
|
|
|
- yield* Fiber.join(s.fiber)
|
|
|
|
|
|
|
+ yield* cachedScan
|
|
|
|
|
+ cachedScan = yield* Effect.cached(
|
|
|
|
|
+ scan().pipe(Effect.catchCause(() => Effect.void)),
|
|
|
|
|
+ )
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
const init = Effect.fn("File.init")(function* () {
|
|
const init = Effect.fn("File.init")(function* () {
|