From f2c65be1036bb5d7310c4a8714e14bb4496efebb Mon Sep 17 00:00:00 2001 From: Stefan Pöschel Date: Fri, 16 Feb 2018 13:48:42 +0100 Subject: SLS: add support to request slides dir re-read A re-read of the slides dir can now be requested by storing a file named `REQUEST_SLIDES_DIR_REREAD` into the slides dir. When the next slide is going to be encoded and this file is present, the slides dir is re-read and this file is deleted. --- src/odr-padenc.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/odr-padenc.cpp') diff --git a/src/odr-padenc.cpp b/src/odr-padenc.cpp index 94f3d68..461502e 100644 --- a/src/odr-padenc.cpp +++ b/src/odr-padenc.cpp @@ -350,8 +350,26 @@ int PadEncoder::EncodeSlide(bool skip_if_already_queued) { return 0; } + // check for slides dir re-read request + std::string request_reread_path = std::string(options.sls_dir) + "/" + SLSEncoder::REQUEST_REREAD_FILENAME; + struct stat request_reread_stat; + if (stat(request_reread_path.c_str(), &request_reread_stat)) { + // ignore missing request file + if (errno != ENOENT) { + perror("ODR-PadEnc Error: could not retrieve slides dir re-read request file stat"); + return 1; + } + } else { + // handle request + fprintf(stderr, "ODR-PadEnc received slides dir re-read request!\n"); + if (unlink(request_reread_path.c_str())) + perror(("ODR-PadEnc Error: erasing file '" + request_reread_path +"' failed").c_str()); + + slides.Clear(); + } + // usually invoked once - for(;;) { + for (;;) { // try to read slides dir (if present) if (slides.Empty()) { if (!slides.InitFromDir(options.sls_dir)) @@ -366,7 +384,7 @@ int PadEncoder::EncodeSlide(bool skip_if_already_queued) { if (sls_encoder.encodeSlide(slide.filepath, slide.fidx, options.raw_slides)) { slides_success = true; if (options.erase_after_tx) { - if (unlink(slide.filepath.c_str()) == -1) + if (unlink(slide.filepath.c_str())) perror(("ODR-PadEnc Error: erasing file '" + slide.filepath +"' failed").c_str()); } } else { -- cgit v1.2.3