microsoft/Windows-classic-samples

Failure in VSS pre and post restore is ignored

kanak-clumio opened this issue · 1 comments

In the source code, after pre and post restore, CheckSelectedWriterStatus() is called to check status of writers. I've copied snippet of code here for prerestore -

            // Issue a PreRestore event to the writers
            m_vssClient.PreRestore();

            // Execute the optional custom command between PreRestore and PostRestore
            try
            {
                // Check selected writer status
                m_vssClient.CheckSelectedWriterStatus();

As per the microsoft documentation, after pre-restore, we need to verify writer status - https://learn.microsoft.com/en-us/windows/win32/vss/overview-of-preparing-for-restore

Here is code of CheckSelectedWriterStatus -

// Check the status for all selected writers
void VssClient::CheckSelectedWriterStatus()
{
    FunctionTracer ft(DBG_INFO);

    if ((m_dwContext & VSS_VOLSNAP_ATTR_NO_WRITERS) != 0)
        return;

Here, the if condition is true in case of restore and hence checking writer status is actually skipped.
If I comment out this if condition and try to perform restore which is supposed to fail in prerestore, it actually fails.

@oldnewthing can you help me with the above?