public bool FileEqualsObject(FileInfo fileInfo, S3ObjectInfo s3Object) { if (s3Object is null) { throw new ArgumentNullException(nameof(s3Object)); } if (fileInfo is null) { throw new ArgumentNullException(nameof(fileInfo)); } _log.PutOut($"Comparison of file {fileInfo.Name} and S3Object {s3Object.Key} started."); if (_inner.FileEqualsObject(fileInfo, s3Object)) { _log.PutOut($"File {fileInfo.Name} matches object {s3Object.Key}."); return(true); } return(false); }
public async Task Synchronize() { await _synchronizationFunctions.Purge().ConfigureAwait(false); var filesInfo = _synchronizationFunctions.GetFilesDictionary(); foreach (var s3Object in await _synchronizationFunctions.GetObjectsList().ConfigureAwait(false)) { if (filesInfo.TryGetValue(s3Object.Key, out var fileInfo)) { filesInfo.Remove(s3Object.Key); if (!_synchronizationFunctions.FileEqualsObject(fileInfo, s3Object)) { await _synchronizationFunctions.UploadMismatchedFile(fileInfo).ConfigureAwait(false); } } else { await _synchronizationFunctions.DeleteExcessObject(s3Object).ConfigureAwait(false); } } await _synchronizationFunctions.UploadMissingFiles(filesInfo.Values).ConfigureAwait(false); }