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 | { |
|
31 | using (var client = new Client(new NetworkCredential()) |
32 | try |
|
32 | { |
33 | { |
|
- | 34 | using (var client = new Client(new NetworkCredential()) |
||
- | 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, |
|
36 | Server = server, |
39 | Server = server, |
|
37 | BasePath = string.Join(@"/", STITCH_CONSTANTS.UPDATE_PATH, |
40 | BasePath = string.Join(@"/", STITCH_CONSTANTS.UPDATE_PATH, |
|
38 | STITCH_CONSTANTS.PROGRESSIVE_PATH) |
41 | STITCH_CONSTANTS.PROGRESSIVE_PATH) |
|
39 | }) |
42 | }) |
|
40 | { |
43 | { |
|
41 | return (await client |
44 | return (await client |
|
42 | .List( |
45 | .List( |
|
43 | string.Join( |
46 | string.Join( |
|
44 | Constants.DIRECTORY_SEPARATOR, |
47 | Constants.DIRECTORY_SEPARATOR, |
|
45 | $"{release.Major}.{release.Minor}", |
- | ||
46 | STITCH_CONSTANTS.UPDATE_DATA_PATH), |
- | ||
47 | Constants.DavDepth.ALL) |
- | ||
48 | ) |
- | ||
49 | .Select(o => string.Join(Constants.DIRECTORY_SEPARATOR, |
- | ||
50 | o.Href.PathSplit(Constants.DIRECTORY_SEPARATOR.First()) |
- | ||
51 | .Select(part => |
- | ||
52 | part.Trim(Constants.DIRECTORY_SEPARATOR.First()).URLUnescapeDataString() |
- | ||
53 | ) |
- | ||
54 | .Where(part => !string.IsNullOrEmpty(part)) |
- | ||
55 | .SequenceExceptAny(new[] { |
- | ||
56 | STITCH_CONSTANTS.UPDATE_PATH, |
- | ||
57 | STITCH_CONSTANTS.PROGRESSIVE_PATH, |
- | ||
58 | $"{release.Major}.{release.Minor}", |
48 | $"{release.Major}.{release.Minor}", |
|
59 | STITCH_CONSTANTS.UPDATE_DATA_PATH |
49 | STITCH_CONSTANTS.UPDATE_DATA_PATH), |
|
60 | }) |
50 | Constants.DavDepth.ALL) |
|
61 | ) |
51 | ) |
|
- | 52 | .Select(o => string.Join(Constants.DIRECTORY_SEPARATOR, |
||
- | 53 | o.Href.PathSplit(Constants.DIRECTORY_SEPARATOR.First()) |
||
- | 54 | .Select(part => |
||
- | 55 | part.Trim(Constants.DIRECTORY_SEPARATOR.First()).URLUnescapeDataString() |
||
- | 56 | ) |
||
- | 57 | .Where(part => !string.IsNullOrEmpty(part)) |
||
- | 58 | .SequenceExceptAny(new[] |
||
- | 59 | { |
||
- | 60 | STITCH_CONSTANTS.UPDATE_PATH, |
||
- | 61 | STITCH_CONSTANTS.PROGRESSIVE_PATH, |
||
- | 62 | $"{release.Major}.{release.Minor}", |
||
- | 63 | STITCH_CONSTANTS.UPDATE_DATA_PATH |
||
- | 64 | }) |
||
- | 65 | ) |
||
62 | ); |
66 | ); |
|
- | 67 | } |
||
- | 68 | } |
||
- | 69 | catch (wasDAVConflictException ex) |
||
- | 70 | { |
||
- | 71 | throw new StitchException(ex); |
||
63 | } |
72 | } |
|
64 | } |
73 | } |
|
Line 65... | Line 74... | |||
65 | |
74 | |
|
66 | /// <summary> |
75 | /// <summary> |
|
Line 70... | Line 79... | |||
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) |
|
74 | { |
83 | { |
|
75 | using (var client = new Client(new NetworkCredential()) |
84 | try |
|
76 | { |
85 | { |
|
- | 86 | using (var client = new Client(new NetworkCredential()) |
||
- | 87 | { |
||
77 | Timeout = timeout, |
88 | Timeout = timeout, |
|
78 | UserAgent = STITCH_CONSTANTS.USER_AGENT.Product.Name, |
89 | UserAgent = STITCH_CONSTANTS.USER_AGENT.Product.Name, |
|
79 | UserAgentVersion = STITCH_CONSTANTS.USER_AGENT.Product.Version, |
90 | UserAgentVersion = STITCH_CONSTANTS.USER_AGENT.Product.Version, |
|
80 | Server = server, |
91 | Server = server, |
|
81 | BasePath = string.Join(@"/", STITCH_CONSTANTS.UPDATE_PATH, |
92 | BasePath = string.Join(@"/", STITCH_CONSTANTS.UPDATE_PATH, |
|
82 | STITCH_CONSTANTS.PROGRESSIVE_PATH) |
93 | STITCH_CONSTANTS.PROGRESSIVE_PATH) |
|
83 | }) |
94 | }) |
|
84 | { |
95 | { |
|
85 | return client |
96 | return client |
|
86 | .List( |
97 | .List( |
|
87 | string.Join( |
98 | string.Join( |
|
88 | Constants.DIRECTORY_SEPARATOR, |
99 | Constants.DIRECTORY_SEPARATOR, |
|
89 | $"{release.Major}.{release.Minor}", |
100 | $"{release.Major}.{release.Minor}", |
|
90 | STITCH_CONSTANTS.UPDATE_DATA_PATH), |
101 | STITCH_CONSTANTS.UPDATE_DATA_PATH), |
|
91 | Constants.DavDepth.ALL) |
102 | Constants.DavDepth.ALL) |
|
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 | } |