diff --git a/C_part/src/nsvg/copy.c b/C_part/src/nsvg/copy.c index 9501cbdb..cbcc2b29 100644 --- a/C_part/src/nsvg/copy.c +++ b/C_part/src/nsvg/copy.c @@ -2,9 +2,11 @@ #include #include #include +#include +#include #include "../utility/logger.h" -#include "../utility/error.h"; +#include "../utility/error.h" const char* TEMPLATE_PATH = "template.svg"; @@ -32,12 +34,17 @@ char* gettemplate(int width, int height) { size_t size; char* data = NULL; fp = fopen(TEMPLATE_PATH, "rb"); + + if(fp == NULL && chdir("./target/release/") == 0) { //couldnt find template here and alternative location DOES exist + fp = fopen(TEMPLATE_PATH, "rb"); + } - if (!fp) { + if(fp == NULL) { //still null after trying fix LOG_ERR("could not find svg template file."); setError(TEMPLATE_FILE_NOT_FOUND); return NULL; }; + fseek(fp, 0, SEEK_END); size = ftell(fp); fseek(fp, 0, SEEK_SET); diff --git a/Dockerfile b/Dockerfile index 92c149ad..0b6a8bd4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,7 +20,7 @@ COPY ./ /home/sjsui/vectorizer/ # set environment variables ENV conanpath /root/.conan/data/ ENV releasebuild true -ENV PATH $PATH:/home/sjsui/vectorizer/Rust_part/target/release/bot +ENV PATH $PATH:/home/sjsui/vectorizer/Rust_part/target/release # initialize build tools WORKDIR /home/sjsui/vectorizer/C_part/build/ @@ -34,4 +34,5 @@ WORKDIR /home/sjsui/vectorizer/Rust_part/ RUN cargo build -vv --release #create entrypoint of container -CMD ["./target/release/trampoline"] \ No newline at end of file +WORKDIR /home/sjsui/vectorizer/Rust_part/target/release/ +CMD ["./trampoline"] \ No newline at end of file diff --git a/Rust_part/src/bot.rs b/Rust_part/src/bot.rs index 6bc20030..93cf79cd 100644 --- a/Rust_part/src/bot.rs +++ b/Rust_part/src/bot.rs @@ -401,7 +401,6 @@ async fn vectorize(ctx: &Context, msg: &Message) -> CommandResult } println!("Sending {0} urls to vectoriser", embed_urls.len()); - println!("Yo Mama {:?}", embed_urls); vectorize_urls(&ctx, &msg, &embed_urls).await; Ok(()) diff --git a/Rust_part/src/trampoline.rs b/Rust_part/src/trampoline.rs index 074420b9..168a7074 100644 --- a/Rust_part/src/trampoline.rs +++ b/Rust_part/src/trampoline.rs @@ -38,6 +38,7 @@ use tokio::time::sleep; use error_show::error_string; use std::sync::Arc; use vecbot::bot::{END_MESSAGE, START_MESSAGE, ERR_MESSAGE}; +use std::env; struct TrampolineData { pub vectorizer: Child, pub vectorizer_finished: bool @@ -139,7 +140,7 @@ async fn start_vectorizer_bot(data: &Arc>) async fn initialize_child(data: &Arc>) { println!("starting vectorizer..."); - let created_process = Command::new("./target/release/bot").spawn().unwrap(); //if path is not absolute, path variable is searched + let created_process = Command::new("bot").spawn().unwrap(); //if path is not absolute, path variable is searched initialize_data_insert(data, created_process).await; }