jbilcke-hf HF staff commited on
Commit
baf7691
·
1 Parent(s): e56af9e

add two servers

Browse files
src/utils/deleteFileIfExists.mts CHANGED
@@ -1,17 +1,19 @@
1
  import { existsSync, promises as fs } from "node:fs"
2
 
3
  export const deleteFileIfExists = async (filePath: string) => {
4
- // this function scares me a bit,
5
- if (filePath === "/" || filePath === "~" || filePath === ".") {
 
 
6
  throw new Error(`lol, no.`)
7
  }
8
 
9
  if (existsSync(filePath)) {
10
  try {
11
- await fs.unlink(filePath)
12
  return true
13
  } catch (err) {
14
- console.log(`failed to delete file ${filePath}`)
15
  }
16
  }
17
  return false
 
1
  import { existsSync, promises as fs } from "node:fs"
2
 
3
  export const deleteFileIfExists = async (filePath: string) => {
4
+
5
+ const safePath = filePath.trim()
6
+ // just a sanity check
7
+ if (safePath.includes("*") ||safePath === "/" || safePath === "~" || safePath === ".") {
8
  throw new Error(`lol, no.`)
9
  }
10
 
11
  if (existsSync(filePath)) {
12
  try {
13
+ await fs.unlink(safePath)
14
  return true
15
  } catch (err) {
16
+ console.log(`failed to delete file ${safePath}`)
17
  }
18
  }
19
  return false
src/utils/generateImageSDXL.mts CHANGED
@@ -3,7 +3,9 @@ import { client } from "@gradio/client"
3
  import { generateSeed } from "../utils/generateSeed.mts"
4
  import { getValidNumber } from "./getValidNumber.mts"
5
 
6
- // we don't use replicas yet, because it ain't easy to get their hostname
 
 
7
  const instances: string[] = [
8
  `${process.env.VC_SDXL_SPACE_API_URL_1 || ""}`,
9
  `${process.env.VC_SDXL_SPACE_API_URL_2 || ""}`,
@@ -19,7 +21,8 @@ const instances: string[] = [
19
  `${process.env.VC_SDXL_SPACE_API_URL_12 || ""}`,
20
  `${process.env.VC_SDXL_SPACE_API_URL_13 || ""}`,
21
  `${process.env.VC_SDXL_SPACE_API_URL_14 || ""}`,
22
-
 
23
  ].filter(instance => instance?.length > 0)
24
 
25
  const secretToken = `${process.env.VC_MICROSERVICE_SECRET_TOKEN || ""}`
 
3
  import { generateSeed } from "../utils/generateSeed.mts"
4
  import { getValidNumber } from "./getValidNumber.mts"
5
 
6
+ // note: to reduce costs we use the small A10s
7
+ // anyway, we will soon not need to use this cloud anymore
8
+ // since we will be able to leverage the Inference API
9
  const instances: string[] = [
10
  `${process.env.VC_SDXL_SPACE_API_URL_1 || ""}`,
11
  `${process.env.VC_SDXL_SPACE_API_URL_2 || ""}`,
 
21
  `${process.env.VC_SDXL_SPACE_API_URL_12 || ""}`,
22
  `${process.env.VC_SDXL_SPACE_API_URL_13 || ""}`,
23
  `${process.env.VC_SDXL_SPACE_API_URL_14 || ""}`,
24
+ `${process.env.VC_SDXL_SPACE_API_URL_15 || ""}`,
25
+ `${process.env.VC_SDXL_SPACE_API_URL_16 || ""}`,
26
  ].filter(instance => instance?.length > 0)
27
 
28
  const secretToken = `${process.env.VC_MICROSERVICE_SECRET_TOKEN || ""}`