update code

This commit is contained in:
lychang
2024-01-12 06:38:54 +08:00
parent 260fe25aaf
commit 89237f3522
3 changed files with 18 additions and 10 deletions

18
Cargo.lock generated
View File

@@ -454,6 +454,15 @@ dependencies = [
"unicode-normalization",
]
[[package]]
name = "imspyder"
version = "1.0.0"
dependencies = [
"bytes",
"reqwest",
"scraper",
]
[[package]]
name = "indexmap"
version = "2.1.0"
@@ -687,15 +696,6 @@ dependencies = [
"windows-targets 0.48.5",
]
[[package]]
name = "pbc"
version = "0.1.0"
dependencies = [
"bytes",
"reqwest",
"scraper",
]
[[package]]
name = "percent-encoding"
version = "2.3.1"

View File

@@ -12,8 +12,11 @@ COPY ./src src
RUN cargo install --path . --color always
# Copy the app to an base Docker image, here we use distroless
FROM debian:bullseye-slim
FROM ubuntu:latest
RUN apt-get update
RUN apt-get install -y ca-certificates
RUN update-ca-certificates
RUN mkdir -p /cache
COPY --from=builder /usr/local/cargo/bin/imspyder /imspyder
USER 1000

View File

@@ -18,6 +18,11 @@ pub(crate) fn write_file(path: &str, content: Bytes) -> Result<(), std::io::Erro
}
pub(crate) fn read_file_string(path: &str) -> Result<String, std::io::Error> {
let path = Path::new(path);
let folder_path = path.parent();
if !folder_path.unwrap().exists() {
fs::create_dir_all(folder_path.unwrap().as_os_str())?;
}
let mut file = File::open(path)?;
let mut contents = String::new();
file.read_to_string(&mut contents)?;