/// <summary> /// Updates the local file copy state if the file has already been transferred (and local DB doesn't know about it). /// </summary> /// <param name="file"></param> /// <param name="fs"></param> private async Task UpdateFileCopyStateIfFileAlreadyExistsAtProvidersAsync(BackupFile file, SourceLocation source, FileStream fs) { // for each provider that needs this file: // > double check that we haven't already transferred this whole file. // > this avoids a full upload if for some reason we have lost our client database state. bool stateChanged = false; foreach (var provider in Providers) { var directory = await Database.GetDirectoryMapItemAsync(file.Directory).ConfigureAwait(false); var providerState = await provider.Value.GetFileStatusAsync(file, source, directory).ConfigureAwait(false); // compare the results from the remote provider to the local known state. // if things are different, then apply the remote state to known local and save the changes. if (file.UpdateLocalStateIfRemoteStateDoesNotMatch(providerState)) { stateChanged = true; } } if (stateChanged) { Logger.WriteTraceMessage("Found a sync mismatch. A provider state does not match local status, updating now.", InstanceID); await Database.UpdateBackupFileCopyStateAsync(file).ConfigureAwait(false); } }