j-chim commited on
Commit
aa29970
·
1 Parent(s): c9c5a30

Add local parquet read support

Browse files
Files changed (1) hide show
  1. lib/duckdb.ts +6 -0
lib/duckdb.ts CHANGED
@@ -8,6 +8,7 @@ import { tmpdir } from "node:os"
8
  import { join } from "node:path"
9
  import { Readable } from "node:stream"
10
  import { pipeline } from "node:stream/promises"
 
11
 
12
  let connectionPromise: Promise<DuckDBConnection> | null = null
13
 
@@ -84,6 +85,11 @@ async function isCachedAndFresh(path: string): Promise<boolean> {
84
  * the rest of the page render.
85
  */
86
  async function ensureLocalParquet(url: string): Promise<string> {
 
 
 
 
 
87
  const cachePath = diskCachePath(url)
88
  if (await isCachedAndFresh(cachePath)) return cachePath
89
  try {
 
8
  import { join } from "node:path"
9
  import { Readable } from "node:stream"
10
  import { pipeline } from "node:stream/promises"
11
+ import { fileURLToPath } from "node:url"
12
 
13
  let connectionPromise: Promise<DuckDBConnection> | null = null
14
 
 
85
  * the rest of the page render.
86
  */
87
  async function ensureLocalParquet(url: string): Promise<string> {
88
+ // file:// SNAPSHOT_URL already points at local disk; skip mirroring.
89
+ // Node's fetch() doesn't support file://, so without this the call
90
+ // would always take the catch path with an opaque "fetch failed".
91
+ if (url.startsWith("file://")) return fileURLToPath(url)
92
+
93
  const cachePath = diskCachePath(url)
94
  if (await isCachedAndFresh(cachePath)) return cachePath
95
  try {