private async Task <Artifact> AddArtifactToDbAsync(DumplingDb dumplingDb, string hash, string localPath, CancellationToken cancelToken) { using (var opTracker = new TrackedOperation("AddArtifactToDbAsync")) { var artifact = new Artifact() { Hash = hash, FileName = Path.GetFileName(localPath), UploadTime = DateTime.UtcNow, Format = ArtifactFormat.Unknown, Uuid = null }; return(await dumplingDb.TryAddAsync(artifact, cancelToken) ? artifact : null); } }
protected virtual async Task <Artifact> CreateArtifactAsync() { FileName = Path.GetFileName(_path).ToLowerInvariant(); CompressedSize = new FileInfo(_path).Length; var artifact = new Artifact { Hash = ExpectedHash, FileName = FileName, Format = ArtifactFormat.Unknown, CompressedSize = CompressedSize, UploadTime = DateTime.UtcNow }; bool newArtifact = await _dumplingDb.TryAddAsync(artifact) == artifact; DumpArtifact dumpArtifact = null; if (DumpId != null) { dumpArtifact = new DumpArtifact() { DumpId = DumpId, LocalPath = LocalPath, DebugCritical = DebugCritical }; _dumplingDb.DumpArtifacts.AddOrUpdate(dumpArtifact); } await _dumplingDb.SaveChangesAsync(); if (newArtifact) { //upload the artifact to blob storage await StoreArtifactBlobAsync(artifact); } return(newArtifact ? artifact : null); }