From 89237f35229ab7b7dad23e4def114bd4456f0931 Mon Sep 17 00:00:00 2001 From: lychang <632945494@qq.com> Date: Fri, 12 Jan 2024 06:38:54 +0800 Subject: [PATCH] update code --- Cargo.lock | 18 +++++++++--------- Dockerfile | 5 ++++- src/file.rs | 5 +++++ 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index df1ebb8..b51e3b1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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" diff --git a/Dockerfile b/Dockerfile index ccef471..89f70a5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/src/file.rs b/src/file.rs index 4514295..6e84683 100644 --- a/src/file.rs +++ b/src/file.rs @@ -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 { + 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)?;