wasStitchNET – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | /////////////////////////////////////////////////////////////////////////// |
2 | // Copyright (C) Wizardry and Steamworks 2017 - License: GNU GPLv3 // |
||
3 | // Please see: http://www.gnu.org/licenses/gpl.html for legal details, // |
||
4 | // rights of fair usage, the disclaimer and warranty conditions. // |
||
5 | /////////////////////////////////////////////////////////////////////////// |
||
6 | |||
7 | using System; |
||
8 | using System.Collections.Generic; |
||
9 | using System.Linq; |
||
10 | using System.Net; |
||
11 | using System.Threading.Tasks; |
||
12 | using wasDAVClient; |
||
13 | using wasSharp; |
||
14 | using wasSharp.Linq; |
||
15 | using wasSharp.Web.Utilities; |
||
16 | |||
17 | namespace wasStitchNET.Repository |
||
18 | { |
||
19 | public class Tools |
||
20 | { |
||
21 | /// <summary> |
||
22 | /// Lists the release files for a given release version. |
||
23 | /// </summary> |
||
24 | /// <param name="server">the Stitch server to use</param> |
||
25 | /// <param name="release">the release to list files for</param> |
||
26 | /// <param name="timeout">the timeout connecting to the Stitch repository</param> |
||
27 | /// <returns>a list of Corrade files contained in the repository</returns> |
||
28 | public static async Task<IEnumerable<string>> GetReleaseFiles(string server, Version release, int timeout) |
||
29 | { |
||
30 | using (var client = new Client(new NetworkCredential()) |
||
31 | { |
||
32 | Timeout = timeout, |
||
33 | UserAgent = STITCH_CONSTANTS.USER_AGENT.Product.Name, |
||
34 | UserAgentVersion = STITCH_CONSTANTS.USER_AGENT.Product.Version, |
||
35 | Server = server, |
||
36 | BasePath = string.Join(@"/", STITCH_CONSTANTS.UPDATE_PATH, |
||
37 | STITCH_CONSTANTS.PROGRESSIVE_PATH) |
||
38 | }) |
||
39 | { |
||
40 | return (await client |
||
41 | .List( |
||
42 | string.Join( |
||
43 | Constants.DIRECTORY_SEPARATOR, |
||
44 | $"{release.Major}.{release.Minor}", |
||
45 | STITCH_CONSTANTS.UPDATE_DATA_PATH), |
||
46 | Constants.DavDepth.ALL) |
||
47 | ) |
||
48 | .Select(o => string.Join(Constants.DIRECTORY_SEPARATOR, |
||
49 | o.Href.PathSplit(Constants.DIRECTORY_SEPARATOR.First()) |
||
50 | .Select(part => |
||
51 | WebExtensions.URLUnescapeDataString( |
||
52 | part.Trim(Constants.DIRECTORY_SEPARATOR.First()) |
||
53 | ) |
||
54 | ) |
||
55 | .Where(part => !string.IsNullOrEmpty(part)) |
||
56 | .SequenceExceptAny(new[] { |
||
57 | STITCH_CONSTANTS.UPDATE_PATH, |
||
58 | STITCH_CONSTANTS.PROGRESSIVE_PATH, |
||
59 | $"{release.Major}.{release.Minor}", |
||
60 | STITCH_CONSTANTS.UPDATE_DATA_PATH |
||
61 | }) |
||
62 | ) |
||
63 | ); |
||
64 | } |
||
65 | } |
||
66 | } |
||
67 | } |