summaryrefslogtreecommitdiff
path: root/src/lib/file_log.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-11-30 00:00:17 +0100
committerCarl Hetherington <cth@carlh.net>2021-11-30 00:01:29 +0100
commit01e979c79f7d0aa20fac1bb24c699e0636168294 (patch)
tree4f2dd067b772969912dd79a41364e5a3a3d38544 /src/lib/file_log.cc
parentb51dca65c6a50063fa65b47a97e86f6e0dbbf911 (diff)
Be a little more careful to handle exceptions from boost::filesystem::file_size
There has been a report of file_size throwing an exception and crashing DCP-o-matic, but I haven't been able to reproduce it yet (possibly related to there being missing content files).
Diffstat (limited to 'src/lib/file_log.cc')
-rw-r--r--src/lib/file_log.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/lib/file_log.cc b/src/lib/file_log.cc
index 5cc9c5569..4d6a0e6ea 100644
--- a/src/lib/file_log.cc
+++ b/src/lib/file_log.cc
@@ -69,7 +69,11 @@ FileLog::head_and_tail (int amount) const
uintmax_t head_amount = amount;
uintmax_t tail_amount = amount;
- uintmax_t size = boost::filesystem::file_size (_file);
+ boost::system::error_code ec;
+ uintmax_t size = boost::filesystem::file_size (_file, ec);
+ if (size == static_cast<uintmax_t>(-1)) {
+ return "";
+ }
if (size < (head_amount + tail_amount)) {
head_amount = size;