Exemplo n.º 1
0
static int restore_metadata(struct asfd *asfd, BFILE *bfd, struct sbuf *sb,
	const char *fname, enum action act,
	int vss_restore, struct cntr *cntr, const char *encryption_password)
{
	int ret=-1;
	size_t metalen=0;
	char *metadata=NULL;
	
	// If it is directory metadata, try to make sure the directory
	// exists. Pass in NULL as the cntr, so no counting is done.
	// The actual directory entry will be coming after the metadata,
	// annoyingly. This is because of the way that the server is queuing
	// up directories to send after file data, so that the stat info on
	// them gets set correctly.
	if(act==ACTION_VERIFY)
	{
		cntr_add(cntr, sb->path.cmd, 1);
		ret=0;
		goto end;
	}

	if(S_ISDIR(sb->statp.st_mode)
	  && restore_dir(asfd, sb, fname, act, cntr, PROTO_1))
		goto end;

	// Read in the metadata...
	if(restore_file_or_get_meta(asfd, bfd, sb, fname, act,
		&metadata, &metalen, vss_restore, cntr, encryption_password))
			goto end;
	if(metadata)
	{
		
		if(!set_extrameta(asfd, bfd, fname,
			sb, metadata, metalen, cntr))
		{
#ifndef HAVE_WIN32
			// Set attributes again, since we just diddled with the
			// file.
			attribs_set(asfd, fname,
				&(sb->statp), sb->winattr, cntr);
			cntr_add(cntr, sb->path.cmd, 1);
#endif
		}
		// Carry on if we could not set_extrameta.
	}
	ret=0;
end:
	free_w(&metadata);
	return ret;
}
Exemplo n.º 2
0
static int restore_metadata(struct asfd *asfd, BFILE *bfd, struct sbuf *sb,
                            const char *fname, enum action act, const char *encpassword,
                            int vss_restore, struct conf *conf)
{
    // If it is directory metadata, try to make sure the directory
    // exists. Pass in NULL as the cntr, so no counting is done.
    // The actual directory entry will be coming after the metadata,
    // annoyingly. This is because of the way that the server is queuing
    // up directories to send after file data, so that the stat info on
    // them gets set correctly.
    if(act==ACTION_RESTORE)
    {
        size_t metalen=0;
        char *metadata=NULL;
        if(S_ISDIR(sb->statp.st_mode)
                && restore_dir(asfd, sb, fname, act, NULL))
            return -1;

        // Read in the metadata...
        if(restore_file_or_get_meta(asfd, bfd, sb,
                                    fname, act, encpassword,
                                    &metadata, &metalen, vss_restore, conf))
            return -1;
        if(metadata)
        {

            if(set_extrameta(asfd,
#ifdef HAVE_WIN32
                             bfd,
#endif
                             fname, sb->path.cmd,
                             &(sb->statp), metadata, metalen, conf))
            {
                free(metadata);
                // carry on if we could not do it
                return 0;
            }
            free(metadata);
#ifndef HAVE_WIN32
            // set attributes again, since we just diddled with
            // the file
            attribs_set(asfd, fname, &(sb->statp), sb->winattr, conf);
#endif
            cntr_add(conf->cntr, sb->path.cmd, 1);
        }
    }
    else cntr_add(conf->cntr, sb->path.cmd, 1);
    return 0;
}