From e7936c8595f183cc0a916a27ff1ac613419a6b92 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Tue, 16 Jan 2018 11:09:26 +0100 Subject: [PATCH] Fixed wrongly deleting a recording that already exists when moving a recording --- recording.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/recording.c b/recording.c index 51013e33..0dd4da5f 100644 --- a/recording.c +++ b/recording.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: recording.c 4.15 2017/12/14 15:14:59 kls Exp $ + * $Id: recording.c 4.16 2018/01/16 11:09:26 kls Exp $ */ #include "recording.h" @@ -1237,7 +1237,10 @@ bool cRecording::ChangeName(const char *NewName) free(name); name = strdup(NewName); cString NewFileName = FileName(); - if (!(MakeDirs(NewFileName, true) && cVideoDirectory::MoveVideoFile(OldFileName, NewFileName))) { + bool Exists = access(NewFileName, F_OK) == 0; + if (Exists) + esyslog("ERROR: recording '%s' already exists", NewName); + if (Exists || !(MakeDirs(NewFileName, true) && cVideoDirectory::MoveVideoFile(OldFileName, NewFileName))) { free(name); name = strdup(OldName); free(fileName);