wasStitchNET – Diff between revs 2 and 3
?pathlinks?
Rev 2 | Rev 3 | |||
---|---|---|---|---|
Line 72... | Line 72... | |||
72 | /// </summary> |
72 | /// </summary> |
|
73 | /// <param name="server">the Stitch server to use</param> |
73 | /// <param name="server">the Stitch server to use</param> |
|
74 | /// <param name="release">the release to list files for</param> |
74 | /// <param name="release">the release to list files for</param> |
|
75 | /// <param name="timeout">the timeout connecting to the Stitch repository</param> |
75 | /// <param name="timeout">the timeout connecting to the Stitch repository</param> |
|
76 | /// <returns>a list of Corrade files contained in the repository</returns> |
76 | /// <returns>a list of Corrade files contained in the repository</returns> |
|
77 | public static async Task<IEnumerable<KeyValuePair<string, string>>> GetReleaseFileHashes(string server, Version release, int timeout) |
77 | public static IEnumerable<KeyValuePair<string, string>> GetReleaseFileHashes(string server, Version release, int timeout) |
|
78 | { |
78 | { |
|
79 | using (var client = new Client(new NetworkCredential()) |
79 | using (var client = new Client(new NetworkCredential()) |
|
80 | { |
80 | { |
|
81 | Timeout = timeout, |
81 | Timeout = timeout, |
|
82 | UserAgent = STITCH_CONSTANTS.USER_AGENT.Product.Name, |
82 | UserAgent = STITCH_CONSTANTS.USER_AGENT.Product.Name, |
|
Line 84... | Line 84... | |||
84 | Server = server, |
84 | Server = server, |
|
85 | BasePath = string.Join(@"/", STITCH_CONSTANTS.UPDATE_PATH, |
85 | BasePath = string.Join(@"/", STITCH_CONSTANTS.UPDATE_PATH, |
|
86 | STITCH_CONSTANTS.PROGRESSIVE_PATH) |
86 | STITCH_CONSTANTS.PROGRESSIVE_PATH) |
|
87 | }) |
87 | }) |
|
88 | { |
88 | { |
|
89 | Console.WriteLine($"{release.Major}.{release.Minor}"); |
- | ||
90 | return (await client |
89 | return client |
|
91 | .List( |
90 | .List( |
|
92 | string.Join( |
91 | string.Join( |
|
93 | Constants.DIRECTORY_SEPARATOR, |
92 | Constants.DIRECTORY_SEPARATOR, |
|
94 | $"{release.Major}.{release.Minor}", |
93 | $"{release.Major}.{release.Minor}", |
|
95 | STITCH_CONSTANTS.UPDATE_DATA_PATH), |
94 | STITCH_CONSTANTS.UPDATE_DATA_PATH), |
|
96 | Constants.DavDepth.ALL) |
95 | Constants.DavDepth.ALL) |
|
97 | ) |
- | ||
98 | .Select(async o => |
- | ||
99 | { |
- | ||
100 | using (var memoryStream = new MemoryStream()) |
- | ||
101 | { |
- | ||
102 | using (var stream = client.Download(o.Href).Result) |
- | ||
103 | { |
96 | .Result |
|
104 | await stream.CopyToAsync(memoryStream); |
- | ||
105 | } |
97 | .AsParallel() |
|
106 | return new KeyValuePair<string, string>( |
98 | .Where(item => !item.IsCollection) |
|
107 | string.Join(Constants.DIRECTORY_SEPARATOR, |
99 | .ToDictionary(o => string.Join(Constants.DIRECTORY_SEPARATOR, |
|
108 | o.Href.PathSplit(Constants.DIRECTORY_SEPARATOR.First()) |
100 | o.Href.PathSplit(Constants.DIRECTORY_SEPARATOR.First()) |
|
109 | .Select(part => |
- | ||
110 | WebExtensions.URLUnescapeDataString( |
101 | .Select(part => WebExtensions.URLUnescapeDataString( |
|
111 | part.Trim(Constants.DIRECTORY_SEPARATOR.First()) |
102 | part.Trim(Constants.DIRECTORY_SEPARATOR.First()) |
|
112 | ) |
103 | ) |
|
113 | ) |
104 | ) |
|
114 | .Where(part => !string.IsNullOrEmpty(part)) |
105 | .Where(part => !string.IsNullOrEmpty(part)) |
|
115 | .SequenceExceptAny(new[] { |
106 | .SequenceExceptAny(new[] { |
|
116 | STITCH_CONSTANTS.UPDATE_PATH, |
107 | STITCH_CONSTANTS.UPDATE_PATH, |
|
117 | STITCH_CONSTANTS.PROGRESSIVE_PATH, |
108 | STITCH_CONSTANTS.PROGRESSIVE_PATH, |
|
118 | $"{release.Major}.{release.Minor}", |
109 | $"{release.Major}.{release.Minor}", |
|
119 | STITCH_CONSTANTS.UPDATE_DATA_PATH |
110 | STITCH_CONSTANTS.UPDATE_DATA_PATH |
|
120 | }) |
- | ||
121 | ), System.Security.Cryptography.SHA1.Create().ToHex(memoryStream)); |
111 | })), o => System.Security.Cryptography.SHA1.Create().ToHex(client.Download(o.Href).Result)); |
|
122 | } |
- | ||
123 | } |
- | ||
124 | ).Select(o => o.Result).OfType<KeyValuePair<string, string>>(); |
- | ||
125 | } |
112 | } |
|
126 | } |
113 | } |
|
127 | } |
114 | } |
|
128 | } |
115 | } |