wasStitchNET – Diff between revs 5 and 10
?pathlinks?
Rev 5 | Rev 10 | |||
---|---|---|---|---|
Line 8... | Line 8... | |||
8 | using System.Collections.Generic; |
8 | using System.Collections.Generic; |
|
9 | using System.Linq; |
9 | using System.Linq; |
|
10 | using System.Net; |
10 | using System.Net; |
|
11 | using System.Threading.Tasks; |
11 | using System.Threading.Tasks; |
|
12 | using wasDAVClient; |
12 | using wasDAVClient; |
|
- | 13 | using wasDAVClient.Helpers; |
||
13 | using wasSharp; |
14 | using wasSharp; |
|
14 | using wasSharp.Linq; |
15 | using wasSharp.Linq; |
|
15 | using wasSharp.Web.Utilities; |
16 | using wasSharp.Web.Utilities; |
|
16 | using wasSharpNET.Cryptography; |
17 | using wasSharpNET.Cryptography; |
|
Line 26... | Line 27... | |||
26 | /// <param name="release">the release to list files for</param> |
27 | /// <param name="release">the release to list files for</param> |
|
27 | /// <param name="timeout">the timeout connecting to the Stitch repository</param> |
28 | /// <param name="timeout">the timeout connecting to the Stitch repository</param> |
|
28 | /// <returns>a list of Corrade files contained in the repository</returns> |
29 | /// <returns>a list of Corrade files contained in the repository</returns> |
|
29 | public static async Task<IEnumerable<string>> GetReleaseFiles(string server, Version release, int timeout) |
30 | public static async Task<IEnumerable<string>> GetReleaseFiles(string server, Version release, int timeout) |
|
30 | { |
31 | { |
|
- | 32 | try |
||
- | 33 | { |
||
31 | using (var client = new Client(new NetworkCredential()) |
34 | using (var client = new Client(new NetworkCredential()) |
|
32 | { |
35 | { |
|
33 | Timeout = timeout, |
36 | Timeout = timeout, |
|
34 | UserAgent = STITCH_CONSTANTS.USER_AGENT.Product.Name, |
37 | UserAgent = STITCH_CONSTANTS.USER_AGENT.Product.Name, |
|
35 | UserAgentVersion = STITCH_CONSTANTS.USER_AGENT.Product.Version, |
38 | UserAgentVersion = STITCH_CONSTANTS.USER_AGENT.Product.Version, |
|
Line 50... | Line 53... | |||
50 | o.Href.PathSplit(Constants.DIRECTORY_SEPARATOR.First()) |
53 | o.Href.PathSplit(Constants.DIRECTORY_SEPARATOR.First()) |
|
51 | .Select(part => |
54 | .Select(part => |
|
52 | part.Trim(Constants.DIRECTORY_SEPARATOR.First()).URLUnescapeDataString() |
55 | part.Trim(Constants.DIRECTORY_SEPARATOR.First()).URLUnescapeDataString() |
|
53 | ) |
56 | ) |
|
54 | .Where(part => !string.IsNullOrEmpty(part)) |
57 | .Where(part => !string.IsNullOrEmpty(part)) |
|
55 | .SequenceExceptAny(new[] { |
58 | .SequenceExceptAny(new[] |
|
- | 59 | { |
||
56 | STITCH_CONSTANTS.UPDATE_PATH, |
60 | STITCH_CONSTANTS.UPDATE_PATH, |
|
57 | STITCH_CONSTANTS.PROGRESSIVE_PATH, |
61 | STITCH_CONSTANTS.PROGRESSIVE_PATH, |
|
58 | $"{release.Major}.{release.Minor}", |
62 | $"{release.Major}.{release.Minor}", |
|
59 | STITCH_CONSTANTS.UPDATE_DATA_PATH |
63 | STITCH_CONSTANTS.UPDATE_DATA_PATH |
|
60 | }) |
64 | }) |
|
61 | ) |
65 | ) |
|
62 | ); |
66 | ); |
|
63 | } |
67 | } |
|
64 | } |
68 | } |
|
- | 69 | catch (wasDAVConflictException ex) |
||
- | 70 | { |
||
- | 71 | throw new StitchException(ex); |
||
- | 72 | } |
||
- | 73 | } |
||
Line 65... | Line 74... | |||
65 | |
74 | |
|
66 | /// <summary> |
75 | /// <summary> |
|
67 | /// Lists the release files for a given release version. |
76 | /// Lists the release files for a given release version. |
|
68 | /// </summary> |
77 | /// </summary> |
|
69 | /// <param name="server">the Stitch server to use</param> |
78 | /// <param name="server">the Stitch server to use</param> |
|
70 | /// <param name="release">the release to list files for</param> |
79 | /// <param name="release">the release to list files for</param> |
|
71 | /// <param name="timeout">the timeout connecting to the Stitch repository</param> |
80 | /// <param name="timeout">the timeout connecting to the Stitch repository</param> |
|
72 | /// <returns>a list of Corrade files contained in the repository</returns> |
81 | /// <returns>a list of Corrade files contained in the repository</returns> |
|
73 | public static IEnumerable<KeyValuePair<string, string>> GetReleaseFileHashes(string server, Version release, int timeout) |
82 | public static IEnumerable<KeyValuePair<string, string>> GetReleaseFileHashes(string server, Version release, int timeout) |
|
- | 83 | { |
||
- | 84 | try |
||
74 | { |
85 | { |
|
75 | using (var client = new Client(new NetworkCredential()) |
86 | using (var client = new Client(new NetworkCredential()) |
|
76 | { |
87 | { |
|
77 | Timeout = timeout, |
88 | Timeout = timeout, |
|
78 | UserAgent = STITCH_CONSTANTS.USER_AGENT.Product.Name, |
89 | UserAgent = STITCH_CONSTANTS.USER_AGENT.Product.Name, |
|
Line 92... | Line 103... | |||
92 | .Result |
103 | .Result |
|
93 | .AsParallel() |
104 | .AsParallel() |
|
94 | .Where(item => !item.IsCollection) |
105 | .Where(item => !item.IsCollection) |
|
95 | .ToDictionary(o => string.Join(Constants.DIRECTORY_SEPARATOR, |
106 | .ToDictionary(o => string.Join(Constants.DIRECTORY_SEPARATOR, |
|
96 | o.Href.PathSplit(Constants.DIRECTORY_SEPARATOR.First()) |
107 | o.Href.PathSplit(Constants.DIRECTORY_SEPARATOR.First()) |
|
97 | .Select(part => part.Trim(Constants.DIRECTORY_SEPARATOR.First()).URLUnescapeDataString() |
108 | .Select(part => part.Trim(Constants.DIRECTORY_SEPARATOR.First()) |
|
- | 109 | .URLUnescapeDataString() |
||
98 | ) |
110 | ) |
|
99 | .Where(part => !string.IsNullOrEmpty(part)) |
111 | .Where(part => !string.IsNullOrEmpty(part)) |
|
100 | .SequenceExceptAny(new[] { |
112 | .SequenceExceptAny(new[] |
|
- | 113 | { |
||
101 | STITCH_CONSTANTS.UPDATE_PATH, |
114 | STITCH_CONSTANTS.UPDATE_PATH, |
|
102 | STITCH_CONSTANTS.PROGRESSIVE_PATH, |
115 | STITCH_CONSTANTS.PROGRESSIVE_PATH, |
|
103 | $"{release.Major}.{release.Minor}", |
116 | $"{release.Major}.{release.Minor}", |
|
104 | STITCH_CONSTANTS.UPDATE_DATA_PATH |
117 | STITCH_CONSTANTS.UPDATE_DATA_PATH |
|
- | 118 | })), |
||
105 | })), o => System.Security.Cryptography.SHA1.Create().ToHex(client.Download(o.Href).Result)); |
119 | o => System.Security.Cryptography.SHA1.Create().ToHex(client.Download(o.Href).Result)); |
|
- | 120 | } |
||
- | 121 | } |
||
- | 122 | catch (wasDAVException ex) |
||
- | 123 | { |
||
- | 124 | throw new StitchException(ex); |
||
106 | } |
125 | } |
|
107 | } |
126 | } |
|
108 | } |
127 | } |
|
109 | } |
128 | } |