aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/odr-padenc.cpp22
-rw-r--r--src/sls.cpp9
-rw-r--r--src/sls.h4
3 files changed, 30 insertions, 5 deletions
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 {
diff --git a/src/sls.cpp b/src/sls.cpp
index 4d24358..8963b65 100644
--- a/src/sls.cpp
+++ b/src/sls.cpp
@@ -3,7 +3,7 @@
Copyright (C) 2014, 2015 Matthias P. Braendli (http://opendigitalradio.org)
- Copyright (C) 2015, 2016, 2017 Stefan Pöschel (http://opendigitalradio.org)
+ Copyright (C) 2015, 2016, 2017, 2018 Stefan Pöschel (http://opendigitalradio.org)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -111,12 +111,16 @@ int SlideStore::FilterSlides(const struct dirent* file) {
if(SLSEncoder::isSlideParamFileFilename(name))
return 0;
+ // skip re-read request file
+ if(name == SLSEncoder::REQUEST_REREAD_FILENAME.c_str())
+ return 0;
+
return 1;
}
bool SlideStore::InitFromDir(const std::string& dir) {
// start with empty list
- slides.clear();
+ Clear();
struct dirent** dir_entries;
int dir_count = scandir(dir.c_str(), &dir_entries, FilterSlides, alphasort);
@@ -257,6 +261,7 @@ const int SLSEncoder::MINQUALITY = 40; // Do not allow the image comp
const std::string SLSEncoder::SLS_PARAMS_SUFFIX = ".sls_params";
const int SLSEncoder::APPTYPE_MOT_START = 12;
const int SLSEncoder::APPTYPE_MOT_CONT = 13;
+const std::string SLSEncoder::REQUEST_REREAD_FILENAME = "REQUEST_SLIDES_DIR_REREAD";
void SLSEncoder::warnOnSmallerImage(size_t height, size_t width, const std::string& fname) {
diff --git a/src/sls.h b/src/sls.h
index 9695544..3d6a407 100644
--- a/src/sls.h
+++ b/src/sls.h
@@ -3,7 +3,7 @@
Copyright (C) 2014, 2015 Matthias P. Braendli (http://opendigitalradio.org)
- Copyright (C) 2015, 2016, 2017 Stefan Pöschel (http://opendigitalradio.org)
+ Copyright (C) 2015, 2016, 2017, 2018 Stefan Pöschel (http://opendigitalradio.org)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -196,6 +196,7 @@ public:
bool InitFromDir(const std::string& dir);
bool Empty() {return slides.empty();}
+ void Clear() {slides.clear();}
slide_metadata_t GetSlide();
};
@@ -247,6 +248,7 @@ private:
public:
static const int APPTYPE_MOT_START;
static const int APPTYPE_MOT_CONT;
+ static const std::string REQUEST_REREAD_FILENAME;
SLSEncoder(PADPacketizer* pad_packetizer) : pad_packetizer(pad_packetizer), cindex_header(0), cindex_body(0) {}