wasStitchNET

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ HEAD  →  ?path2? @ 1
File deleted
\ No newline at end of file
/Repository/Files.cs
File deleted
\ No newline at end of file
/Repository/StitchOptions.cs
File deleted
\ No newline at end of file
/Repository/Hashing.cs
File deleted
\ No newline at end of file
/Repository/Mirrors.cs
File deleted
\ No newline at end of file
/Repository/Stitching/StitchProgressEvent.cs
File deleted
\ No newline at end of file
/Repository/Stitching/Stitching.cs
/Repository/Tools.cs
@@ -10,12 +10,9 @@
using System.Net;
using System.Threading.Tasks;
using wasDAVClient;
using wasDAVClient.Helpers;
using wasSharp;
using wasSharp.Sets;
using wasSharp.Linq;
using wasSharp.Web.Utilities;
using wasSharpNET.Cryptography;
using SHA1 = System.Security.Cryptography.SHA1;
 
namespace wasStitchNET.Repository
{
@@ -30,101 +27,41 @@
/// <returns>a list of Corrade files contained in the repository</returns>
public static async Task<IEnumerable<string>> GetReleaseFiles(string server, Version release, int timeout)
{
try
using (var client = new Client(new NetworkCredential())
{
using (var client = new Client(new NetworkCredential())
{
Timeout = timeout,
UserAgent = STITCH_CONSTANTS.USER_AGENT.Product.Name,
UserAgentVersion = STITCH_CONSTANTS.USER_AGENT.Product.Version,
Server = server,
BasePath = string.Join(@"/", STITCH_CONSTANTS.UPDATE_PATH,
STITCH_CONSTANTS.PROGRESSIVE_PATH)
})
{
return (await client
.List(
string.Join(
Constants.DIRECTORY_SEPARATOR,
$"{release.Major}.{release.Minor}",
STITCH_CONSTANTS.UPDATE_DATA_PATH),
Constants.DavDepth.ALL)
)
.Select(o => string.Join(Constants.DIRECTORY_SEPARATOR,
o.Href.PathSplit(Constants.DIRECTORY_SEPARATOR.First())
.Select(part =>
part.Trim(Constants.DIRECTORY_SEPARATOR.First()).URLUnescapeDataString()
)
.Where(part => !string.IsNullOrEmpty(part))
.SequenceExceptAny(new[]
{
STITCH_CONSTANTS.UPDATE_PATH,
STITCH_CONSTANTS.PROGRESSIVE_PATH,
$"{release.Major}.{release.Minor}",
STITCH_CONSTANTS.UPDATE_DATA_PATH
})
)
);
}
}
catch (wasDAVConflictException ex)
Timeout = timeout,
UserAgent = STITCH_CONSTANTS.USER_AGENT.Product.Name,
UserAgentVersion = STITCH_CONSTANTS.USER_AGENT.Product.Version,
Server = server,
BasePath = string.Join(@"/", STITCH_CONSTANTS.UPDATE_PATH,
STITCH_CONSTANTS.PROGRESSIVE_PATH)
})
{
throw new StitchException(ex);
}
}
 
/// <summary>
/// Lists the release files for a given release version.
/// </summary>
/// <param name="server">the Stitch server to use</param>
/// <param name="release">the release to list files for</param>
/// <param name="timeout">the timeout connecting to the Stitch repository</param>
/// <returns>a list of Corrade files contained in the repository</returns>
public static IEnumerable<KeyValuePair<string, string>> GetReleaseFileHashes(string server, Version release,
int timeout)
{
try
{
using (var client = new Client(new NetworkCredential())
{
Timeout = timeout,
UserAgent = STITCH_CONSTANTS.USER_AGENT.Product.Name,
UserAgentVersion = STITCH_CONSTANTS.USER_AGENT.Product.Version,
Server = server,
BasePath = string.Join(@"/", STITCH_CONSTANTS.UPDATE_PATH,
STITCH_CONSTANTS.PROGRESSIVE_PATH)
})
{
return client
.List(
string.Join(
Constants.DIRECTORY_SEPARATOR,
$"{release.Major}.{release.Minor}",
STITCH_CONSTANTS.UPDATE_DATA_PATH),
return (await client
.List(
string.Join(
Constants.DIRECTORY_SEPARATOR,
$"{release.Major}.{release.Minor}",
STITCH_CONSTANTS.UPDATE_DATA_PATH),
Constants.DavDepth.ALL)
.Result
.AsParallel()
.Where(item => !item.IsCollection)
.ToDictionary(o => string.Join(Constants.DIRECTORY_SEPARATOR,
o.Href.PathSplit(Constants.DIRECTORY_SEPARATOR.First())
.Select(part => part.Trim(Constants.DIRECTORY_SEPARATOR.First())
.URLUnescapeDataString()
)
.Select(o => string.Join(Constants.DIRECTORY_SEPARATOR,
o.Href.PathSplit(Constants.DIRECTORY_SEPARATOR.First())
.Select(part =>
WebExtensions.URLUnescapeDataString(
part.Trim(Constants.DIRECTORY_SEPARATOR.First())
)
.Where(part => !string.IsNullOrEmpty(part))
.SequenceExceptAny(new[]
{
STITCH_CONSTANTS.UPDATE_PATH,
STITCH_CONSTANTS.PROGRESSIVE_PATH,
$"{release.Major}.{release.Minor}",
STITCH_CONSTANTS.UPDATE_DATA_PATH
})),
o => SHA1.Create().ToHex(client.Download(o.Href).Result));
}
)
.Where(part => !string.IsNullOrEmpty(part))
.SequenceExceptAny(new[] {
STITCH_CONSTANTS.UPDATE_PATH,
STITCH_CONSTANTS.PROGRESSIVE_PATH,
$"{release.Major}.{release.Minor}",
STITCH_CONSTANTS.UPDATE_DATA_PATH
})
)
);
}
catch (wasDAVException ex)
{
throw new StitchException(ex);
}
}
}
}
}