Modified EntriesOnSameFileSystem(), so that it returns 'true' if either of the given; changed handling the 'error' variable in cDirCopier

This commit is contained in:
Klaus Schmidinger 2015-02-07 16:08:13 +01:00
parent 202a6b3072
commit 8225d3758f
5 changed files with 15 additions and 6 deletions

View File

@ -2420,6 +2420,7 @@ Christoph Haubrich <christoph1.haubrich@arcor.de>
for reporting a bug in setting an empty recording name or folder to a blank in the for reporting a bug in setting an empty recording name or folder to a blank in the
"Edit recording" menu "Edit recording" menu
for suggesting to add a confirmation before renaming a recording to its folder name for suggesting to add a confirmation before renaming a recording to its folder name
for reporting a problem with data loss in case renaming a recording fails
Pekka Mauno <pekka.mauno@iki.fi> Pekka Mauno <pekka.mauno@iki.fi>
for fixing cSchedule::GetFollowingEvent() in case there is currently no present for fixing cSchedule::GetFollowingEvent() in case there is currently no present

View File

@ -8515,3 +8515,8 @@ Video Disk Recorder Revision History
menu (reported by Christoph Haubrich). menu (reported by Christoph Haubrich).
- Added a confirmation before renaming a recording to its folder name (suggested - Added a confirmation before renaming a recording to its folder name (suggested
by Christoph Haubrich). by Christoph Haubrich).
- Modified EntriesOnSameFileSystem(), so that it returns 'true' if either of the given
files doesn't exist (to avoid any actions that might be triggered if files are on
different file system), and changed handling the 'error' variable in cDirCopier, so
that it is initialized to 'true' and will only be set to 'false' if the entire
copy process has been successful (problem reported by Christoph Haubrich).

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: recording.c 3.26 2015/02/06 15:13:59 kls Exp $ * $Id: recording.c 3.27 2015/02/07 16:07:22 kls Exp $
*/ */
#include "recording.h" #include "recording.h"
@ -1676,7 +1676,7 @@ cDirCopier::cDirCopier(const char *DirNameSrc, const char *DirNameDst)
{ {
dirNameSrc = DirNameSrc; dirNameSrc = DirNameSrc;
dirNameDst = DirNameDst; dirNameDst = DirNameDst;
error = false; error = true; // prepare for the worst!
suspensionLogged = false; suspensionLogged = false;
} }
@ -1790,6 +1790,7 @@ void cDirCopier::Action(void)
else { else {
// We're done: // We're done:
dsyslog("done copying directory '%s' to '%s'", *dirNameSrc, *dirNameDst); dsyslog("done copying directory '%s' to '%s'", *dirNameSrc, *dirNameDst);
error = false;
return; return;
} }
} }
@ -1802,7 +1803,6 @@ void cDirCopier::Action(void)
} }
else else
esyslog("ERROR: can't access '%s'", *dirNameDst); esyslog("ERROR: can't access '%s'", *dirNameDst);
error = true;
} }
void cDirCopier::Stop(void) void cDirCopier::Stop(void)

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: tools.c 3.3 2014/03/22 14:22:55 kls Exp $ * $Id: tools.c 3.4 2015/02/07 16:07:22 kls Exp $
*/ */
#include "tools.h" #include "tools.h"
@ -404,7 +404,7 @@ bool EntriesOnSameFileSystem(const char *File1, const char *File2)
} }
else else
LOG_ERROR_STR(File1); LOG_ERROR_STR(File1);
return false; return true; // we only return false if both files actually exist and are in different file systems!
} }
int FreeDiskSpaceMB(const char *Directory, int *UsedMB) int FreeDiskSpaceMB(const char *Directory, int *UsedMB)

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: tools.h 3.6 2015/01/14 09:09:06 kls Exp $ * $Id: tools.h 3.7 2015/02/07 16:07:22 kls Exp $
*/ */
#ifndef __TOOLS_H #ifndef __TOOLS_H
@ -234,6 +234,9 @@ cString dtoa(double d, const char *Format = "%f");
cString itoa(int n); cString itoa(int n);
cString AddDirectory(const char *DirName, const char *FileName); cString AddDirectory(const char *DirName, const char *FileName);
bool EntriesOnSameFileSystem(const char *File1, const char *File2); bool EntriesOnSameFileSystem(const char *File1, const char *File2);
///< Checks whether the given files are on the same file system. If either of the
///< files doesn't exist, this function returns *true* to avoid any actions that might be
///< triggered if files are on different file system.
int FreeDiskSpaceMB(const char *Directory, int *UsedMB = NULL); int FreeDiskSpaceMB(const char *Directory, int *UsedMB = NULL);
bool DirectoryOk(const char *DirName, bool LogErrors = false); bool DirectoryOk(const char *DirName, bool LogErrors = false);
bool MakeDirs(const char *FileName, bool IsDirectory = false); bool MakeDirs(const char *FileName, bool IsDirectory = false);