Skip to content

Commit

Permalink
For a command plugin always use the no_read field of savepkt
Browse files Browse the repository at this point in the history
A command plugin can set the no_read flag in the savepkt returned by the
startBackupFile() method in the plugin events. Up until now setting this
no_read flag to true would not make a lot of difference as the code only
checks for 'ff_pkt->cmd_plugin && !ff_pkt->no_read' to enable the
do_read variable but if the do_read was already set to true and the
plugin has set no_read to true then do_read will never be set to false
again.

These changes make the no_read flag from the plugin leading and always
use that setting (which is false by default) as the setting to determine
the do_read flag. Only for a non cmd-plugin we will determine the actual
reading of the file or not by looking at the specific file type.
  • Loading branch information
Marco van Wieringen committed May 7, 2015
1 parent f780a23 commit f10d372
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions src/filed/backup.c
Expand Up @@ -727,28 +727,33 @@ int save_file(JCR *jcr, FF_PKT *ff_pkt, bool top_level)
}

/*
* Open any file with data that we intend to save, then save it.
*
* Note, if is_win32_backup, we must open the Directory so that
* the BackupRead will save its permissions and ownership streams.
* For a command plugin use the setting from the plugins savepkt no_read field
* which is saved in the ff_pkt->no_read variable. do_read is the inverted
* value of this variable as no_read == TRUE means do_read == FALSE
*/
if (ff_pkt->type != FT_LNKSAVED && S_ISREG(ff_pkt->statp.st_mode)) {
if (ff_pkt->cmd_plugin) {
do_read = !ff_pkt->no_read;
} else {
/*
* Open any file with data that we intend to save, then save it.
*
* Note, if is_win32_backup, we must open the Directory so that
* the BackupRead will save its permissions and ownership streams.
*/
if (ff_pkt->type != FT_LNKSAVED && S_ISREG(ff_pkt->statp.st_mode)) {
#ifdef HAVE_WIN32
do_read = !is_portable_backup(&ff_pkt->bfd) || ff_pkt->statp.st_size > 0;
do_read = !is_portable_backup(&ff_pkt->bfd) || ff_pkt->statp.st_size > 0;
#else
do_read = ff_pkt->statp.st_size > 0;
do_read = ff_pkt->statp.st_size > 0;
#endif
} else if (ff_pkt->type == FT_RAW ||
ff_pkt->type == FT_FIFO ||
ff_pkt->type == FT_REPARSE ||
ff_pkt->type == FT_JUNCTION ||
(!is_portable_backup(&ff_pkt->bfd) &&
ff_pkt->type == FT_DIREND)) {
do_read = true;
}

if (ff_pkt->cmd_plugin && !ff_pkt->no_read) {
do_read = true;
} else if (ff_pkt->type == FT_RAW ||
ff_pkt->type == FT_FIFO ||
ff_pkt->type == FT_REPARSE ||
ff_pkt->type == FT_JUNCTION ||
(!is_portable_backup(&ff_pkt->bfd) &&
ff_pkt->type == FT_DIREND)) {
do_read = true;
}
}

Dmsg2(150, "type=%d do_read=%d\n", ff_pkt->type, do_read);
Expand Down

0 comments on commit f10d372

Please sign in to comment.