mirror of
https://fastgit.cc/https://github.com/anomalyco/opencode
synced 2026-04-20 21:00:29 +08:00
refactor: use InstanceState context in File service
This commit is contained in:
@@ -11,7 +11,6 @@ import ignore from "ignore"
|
||||
import path from "path"
|
||||
import z from "zod"
|
||||
import { Global } from "../global"
|
||||
import { Instance } from "../project/instance"
|
||||
import { Log } from "../util"
|
||||
import { Protected } from "./protected"
|
||||
import { Ripgrep } from "./ripgrep"
|
||||
@@ -513,6 +512,7 @@ export const layer = Layer.effect(
|
||||
const ctx = yield* InstanceState.context
|
||||
const full = path.join(ctx.directory, file)
|
||||
|
||||
<<<<<<< HEAD
|
||||
if (!Instance.containsPath(full, ctx)) {
|
||||
throw new Error("Access denied: path escapes project directory")
|
||||
}
|
||||
@@ -592,6 +592,7 @@ export const layer = Layer.effect(
|
||||
ignored = ig.ignores.bind(ig)
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
const resolved = dir ? path.join(ctx.directory, dir) : ctx.directory
|
||||
if (!Instance.containsPath(resolved, ctx)) {
|
||||
throw new Error("Access denied: path escapes project directory")
|
||||
|
||||
Reference in New Issue
Block a user