-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added simple Client for Microsoft Store
No clue at all if it works, more doing this so I can plan out what I'm doing for clients * Revert some BSDiff changes which caused it to break * ICollection -> IReadOnlyCollection in IUpdatePackage
- Loading branch information
Showing
28 changed files
with
265 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
src/Clients/TinyUpdate.MicrosoftStore/MicrosoftStoreClient.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using Windows.Services.Store; | ||
using Microsoft.Extensions.Logging; | ||
using TinyUpdate.Core.Abstract; | ||
|
||
namespace TinyUpdate.MicrosoftStore; | ||
|
||
public class MicrosoftStoreClient(StoreContext storeContext, ILogger logger) : IPackageClient | ||
{ | ||
public async Task<IEnumerable<ReleaseEntry>> GetUpdates() | ||
{ | ||
var storePackageUpdates = await storeContext.GetAppAndOptionalStorePackageUpdatesAsync(); | ||
return [new MicrosoftStoreReleaseEntry(storePackageUpdates)]; | ||
} | ||
|
||
public async Task<bool> DownloadUpdate(ReleaseEntry releaseEntry, IProgress<double>? progress) | ||
{ | ||
if (releaseEntry is not MicrosoftStoreReleaseEntry microsoftStoreReleaseEntry) | ||
{ | ||
logger.LogError("Wasn't given a microsoft store update entry"); | ||
return false; | ||
} | ||
|
||
var downloadOperation = storeContext.RequestDownloadStorePackageUpdatesAsync(microsoftStoreReleaseEntry | ||
.StorePackageUpdates); | ||
|
||
downloadOperation.Progress = (_, progressStatus) => progress?.Report(progressStatus.PackageDownloadProgress); | ||
|
||
var downloadResult = await downloadOperation.AsTask(); | ||
return downloadResult.OverallState == StorePackageUpdateState.Completed; | ||
} | ||
|
||
public async Task<bool> ApplyUpdate(ReleaseEntry releaseEntry, IProgress<double>? progress) | ||
{ | ||
//No need to actually do an update, report as successful | ||
if (!releaseEntry.HasUpdate) | ||
{ | ||
progress?.Report(1); | ||
return true; | ||
} | ||
|
||
if (releaseEntry is not MicrosoftStoreReleaseEntry microsoftStoreReleaseEntry) | ||
{ | ||
logger.LogError("Wasn't given a microsoft store update entry"); | ||
return false; | ||
} | ||
|
||
//TODO: Find out if the 0.8 - 1 applies here? | ||
var installOperation = storeContext.RequestDownloadAndInstallStorePackageUpdatesAsync(microsoftStoreReleaseEntry | ||
.StorePackageUpdates); | ||
|
||
installOperation.Progress = (_, progressStatus) => progress?.Report(progressStatus.TotalDownloadProgress); | ||
var installResult = await installOperation.AsTask(); | ||
return installResult.OverallState == StorePackageUpdateState.Completed; | ||
} | ||
} | ||
|
||
public class MicrosoftStoreReleaseEntry : ReleaseEntry | ||
{ | ||
public MicrosoftStoreReleaseEntry(IReadOnlyList<StorePackageUpdate>? storePackageUpdates) | ||
{ | ||
StorePackageUpdates = storePackageUpdates ?? ArraySegment<StorePackageUpdate>.Empty; | ||
} | ||
|
||
public IReadOnlyList<StorePackageUpdate> StorePackageUpdates { get; } | ||
public override bool HasUpdate => StorePackageUpdates.Count > 0; | ||
} |
13 changes: 13 additions & 0 deletions
13
src/Clients/TinyUpdate.MicrosoftStore/TinyUpdate.MicrosoftStore.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0-windows10.0.17763.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\TinyUpdate.Core\TinyUpdate.Core.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
using TinyUpdate.Core; | ||
using TinyUpdate.Core.Model; | ||
|
||
namespace TinyUpdate.TUUP; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...TinyUpdate.Core/Abstract/IDeltaApplier.cs → ...date.Core/Abstract/Delta/IDeltaApplier.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...inyUpdate.Core/Abstract/IDeltaCreation.cs → ...ate.Core/Abstract/Delta/IDeltaCreation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...TinyUpdate.Core/Abstract/IDeltaManager.cs → ...date.Core/Abstract/Delta/IDeltaManager.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/TinyUpdate.Core/Abstract/Delta/IDeltaUpdatePackageCreator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using SemVersion; | ||
|
||
namespace TinyUpdate.Core.Abstract.Delta; | ||
|
||
/// <summary> | ||
/// Provides base functionality for creating delta update packages | ||
/// </summary> | ||
public interface IDeltaUpdatePackageCreator : IExtension | ||
{ | ||
/// <summary> | ||
/// Template for a delta package filename (Null if not supported) | ||
/// </summary> | ||
string DeltaPackageFilenameTemplate { get; } | ||
|
||
/// <summary> | ||
/// Creates a delta update package | ||
/// </summary> | ||
/// <param name="previousApplicationLocation">Where the previous version of the application is located</param> | ||
/// <param name="previousApplicationVersion">What the previous version of the application is</param> | ||
/// <param name="newApplicationLocation">Where the new version of the application is located</param> | ||
/// <param name="newApplicationVersion">What the new version of the application is</param> | ||
/// <param name="updatePackageLocation">Where we should store the created update package</param> | ||
/// <param name="applicationName">The applications name</param> | ||
/// <param name="progress">Process about creating the update package</param> | ||
/// <returns>If we successfully created the update package</returns> | ||
Task<bool> CreateDeltaPackage(string previousApplicationLocation, SemanticVersion previousApplicationVersion, string newApplicationLocation, SemanticVersion newApplicationVersion, string updatePackageLocation, string applicationName, IProgress<double>? progress = null); | ||
} |
Oops, something went wrong.