From e9c9c1a3a91bce295f15f4d9ac5834741f2caaa2 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 22 Apr 2011 09:59:28 +0000 Subject: Remove duplicate code by caching the relative path of the backup location after the volume name has been removed (VSS). --- bin/bbackupd/BackupDaemon.cpp | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) (limited to 'bin') diff --git a/bin/bbackupd/BackupDaemon.cpp b/bin/bbackupd/BackupDaemon.cpp index 6dd0ad38..c7afaa89 100644 --- a/bin/bbackupd/BackupDaemon.cpp +++ b/bin/bbackupd/BackupDaemon.cpp @@ -1326,6 +1326,7 @@ void BackupDaemon::CreateVssBackupComponents() volumesIncluded[path[0]] = newVolumeId; rLocation.mSnapshotVolumeId = newVolumeId; rLocation.mIsSnapshotCreated = true; + rLocation.mSnapshotPath = path; } else { @@ -1446,32 +1447,13 @@ void BackupDaemon::CreateVssBackupComponents() Location& rLocation(**iLocation); if(rLocation.mIsSnapshotCreated) { - std::string path = rLocation.mPath; - // convert to absolute and remove leading \\?\ - path = ConvertPathToAbsoluteUnicode(path.c_str()); - std::string volume = path.substr(4, 3); - path = path.substr(7); - char driveLetter = volume[0]; - - std::map::iterator iVssId = - volumesIncluded.find(driveLetter); - - if(iVssId == volumesIncluded.end()) - { - BOX_ERROR("VSS: Failed to find snapshot ID for " - "volume " << volume << " for location " << - rLocation.mPath); - rLocation.mIsSnapshotCreated = false; - continue; - } - VSS_SNAPSHOT_PROP prop; - result = mpVssBackupComponents->GetSnapshotProperties(iVssId->second, - &prop); + result = mpVssBackupComponents->GetSnapshotProperties( + rLocation.mSnapshotVolumeId, &prop); if(result != S_OK) { BOX_ERROR("VSS: Failed to get snapshot properties " - "for volume " << GuidToString(iVssId->second) << + "for volume " << GuidToString(rLocation.mSnapshotVolumeId) << " for location " << rLocation.mPath << ": " << GetMsgForHresult(result)); rLocation.mIsSnapshotCreated = false; @@ -1480,7 +1462,7 @@ void BackupDaemon::CreateVssBackupComponents() rLocation.mSnapshotPath = WideStringToString(prop.m_pwszSnapshotDeviceObject) + - DIRECTORY_SEPARATOR + path; + DIRECTORY_SEPARATOR + rLocation.mSnapshotPath; FreeSnapshotProp(&prop); BOX_INFO("VSS: Location " << rLocation.mPath << " using " -- cgit v1.2.3