(path: string)
| 59 | } |
| 60 | |
| 61 | async function readFileWithSudo(path: string): Promise<string | null> { |
| 62 | try { |
| 63 | return (await fs.promises.readFile(path, "utf8")).trim(); |
| 64 | } catch (err: any) { |
| 65 | if (err.code !== "EACCES" && err.code !== "EPERM") { |
| 66 | return null; |
| 67 | } |
| 68 | logger.info(`File requires elevated privileges, retrying with sudo: ${path}`); |
| 69 | try { |
| 70 | const { stdout } = await runFile("sudo", ["-n", "cat", path]); |
| 71 | return (stdout || "").trim(); |
| 72 | } catch { |
| 73 | return null; |
| 74 | } |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | export interface BandwidthLimit { |
| 79 | uploadLimit?: number; |
no test coverage detected