private async Task ImportFile( IFileSource source, IFileInfo file, CancellationToken token) { var fileName = Path.GetFileName(file.Path); try { var scale = source.Config.Scale; var rotation = source.Config.Rotation; var(hash, geoInfo, resolution) = await RebuildPreview(source, file.Path, rotation, scale); var tags = source.GetTags(file.Path); var previewInfo = new PreviewInfo { ItemName = fileName, FileHash = hash, Tags = tags.ToHashSet(), Resolution = resolution }; _lock.Write(() => { if (token.IsCancellationRequested) { return; } _tagManager.Add(tags); var model = _previewModels.AddOrUpdate(source, file, previewInfo, geoInfo); _previewStreams.ForEach(stream => stream.AddFiltered(model)); _relay.Send(this, new ProgressMessage { Text = $"Imported `{fileName}`" }); }); } catch (Exception ex) { var text = $"Error while importing `{fileName}`"; _relay.Send <ProgressMessage>(new ProgressMessage { Text = text }); Logger.Error(ex, text); } }