import { promises as fs } from "fs";
import { resolveContainedPath, resolveLegacyPublicRoot } from "../pathContainment.js";
class LegacyPublicStorageDriver {
  constructor() {
    this.key = "legacyPublic";
  }
  store(_payload) {
    throw new Error("legacy-public driver is read-only");
  }
  async read(_partitionCode, storagePath) {
    const absolutePath = this.resolveAbsolutePath(storagePath);
    const buffer = await fs.readFile(absolutePath);
    return { buffer };
  }
  async delete(_partitionCode, storagePath) {
    const absolutePath = this.resolveAbsolutePath(storagePath);
    try {
      await fs.unlink(absolutePath);
    } catch {
    }
  }
  async toLocalPath(_partitionCode, storagePath) {
    return {
      filePath: this.resolveAbsolutePath(storagePath),
      cleanup: async () => {
      }
    };
  }
  resolveAbsolutePath(storagePath) {
    return resolveContainedPath(process.cwd(), storagePath, resolveLegacyPublicRoot());
  }
}
export {
  LegacyPublicStorageDriver
};
//# sourceMappingURL=legacyPublicDriver.js.map
