(path: string)
| 988 | } |
| 989 | |
| 990 | async deleteFile(path: string): Promise<boolean> { |
| 991 | await this.ensureInit(); |
| 992 | const normalized = normalizePath(path); |
| 993 | const T = this.tableName; |
| 994 | const rows = await this.sql.query<{ |
| 995 | type: string; |
| 996 | storage_backend: string; |
| 997 | r2_key: string | null; |
| 998 | }>( |
| 999 | `SELECT type, storage_backend, r2_key FROM ${T} WHERE path = ?`, |
| 1000 | normalized |
| 1001 | ); |
| 1002 | if (!rows[0]) return false; |
| 1003 | if (rows[0].type === "directory") |
| 1004 | throw new Error(`EISDIR: ${path} is a directory — use rm() instead`); |
| 1005 | |
| 1006 | if (rows[0].storage_backend === "r2" && rows[0].r2_key) { |
| 1007 | const r2 = this.getR2(); |
| 1008 | if (r2) await r2.delete(rows[0].r2_key); |
| 1009 | } |
| 1010 | |
| 1011 | await this.sql.run(`DELETE FROM ${T} WHERE path = ?`, normalized); |
| 1012 | this.emit("delete", normalized, rows[0].type as EntryType); |
| 1013 | this._observe("workspace:delete", { path: normalized }); |
| 1014 | return true; |
| 1015 | } |
| 1016 | |
| 1017 | async fileExists(path: string): Promise<boolean> { |
| 1018 | await this.ensureInit(); |
no test coverage detected