aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/stream.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2021-09-16 17:21:20 +0200
committerThomas White <taw@physics.org>2022-06-02 12:15:38 +0200
commit6db9619ba5172b9e416a5939d375f5119aa652ff (patch)
treed6dc4a11bddd801a15adaa03b3c2b1973fcd542b /libcrystfel/src/stream.c
parent1638ec5dc997f0c0fa35ed4fb4f23ed117aafae4 (diff)
Refuse to overwrite an existing stream
With online processing, we might end up with a very long stream. It should not be so easily deleted if indexamajig is restarted!
Diffstat (limited to 'libcrystfel/src/stream.c')
-rw-r--r--libcrystfel/src/stream.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/libcrystfel/src/stream.c b/libcrystfel/src/stream.c
index 093e34e4..67297e49 100644
--- a/libcrystfel/src/stream.c
+++ b/libcrystfel/src/stream.c
@@ -1167,6 +1167,11 @@ Stream *stream_open_for_write(const char *filename,
st->dtempl_write = dtempl;
st->dtempl_read = NULL;
+ if ( file_exists(filename) ) {
+ ERROR("Refusing to overwrite stream '%s'!\n", filename);
+ return NULL;
+ }
+
st->fh = fopen(filename, "w");
if ( st->fh == NULL ) {
ERROR("Failed to open stream.\n");