This repository was archived by the owner on Mar 31, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathPackageFileToCsvDriver.cs
More file actions
70 lines (59 loc) · 2.5 KB
/
PackageFileToCsvDriver.cs
File metadata and controls
70 lines (59 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#nullable enable
using Knapcode.MiniZip;
namespace NuGet.Insights.Worker.PackageFileToCsv
{
public class PackageFileToCsvDriver : FullZipArchiveEntryToCsvDriver<PackageFileRecord>
{
private readonly PackageFileService _fileService;
private readonly FlatContainerClient _client;
private readonly IOptions<NuGetInsightsWorkerSettings> _options;
public PackageFileToCsvDriver(
CatalogClient catalogClient,
PackageFileService fileService,
PackageHashService hashService,
FlatContainerClient client,
FileDownloader fileDownloader,
IOptions<NuGetInsightsWorkerSettings> options,
ILogger<PackageFileToCsvDriver> logger)
: base(
catalogClient,
fileDownloader,
hashService,
logger)
{
_fileService = fileService;
_client = client;
_options = options;
}
public override string ResultContainerName => _options.Value.PackageFileContainerName;
protected override bool NotFoundIsDeleted => true;
protected override ArtifactFileType FileType => ArtifactFileType.Nupkg;
protected override async Task<ZipDirectory?> GetZipDirectoryAsync(IPackageIdentityCommit leafItem)
{
var info = await _fileService.GetZipDirectoryAndLengthAsync(leafItem);
if (!info.HasValue)
{
return null;
}
return info.Value.Directory;
}
protected override async Task<string> GetZipUrlAsync(CatalogLeafScan leafScan)
{
return await _client.GetPackageContentUrlAsync(leafScan.PackageId, leafScan.PackageVersion);
}
protected override async Task InternalInitializeAsync()
{
await _fileService.InitializeAsync();
}
protected override PackageFileRecord NewDeleteRecord(Guid scanId, DateTimeOffset scanTimestamp, PackageDeleteCatalogLeaf leaf)
{
return new PackageFileRecord(scanId, scanTimestamp, leaf);
}
protected override PackageFileRecord NewDetailsRecord(Guid scanId, DateTimeOffset scanTimestamp, PackageDetailsCatalogLeaf leaf)
{
return new PackageFileRecord(scanId, scanTimestamp, leaf);
}
}
}