Skip to content

Commit

Permalink
Updater x64 support and refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
rocksdanister committed May 2, 2024
1 parent 8dd989b commit 5ac3255
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 46 deletions.
28 changes: 23 additions & 5 deletions src/Lively/Lively.Common.Services/Update/GithubUpdaterService.cs
Expand Up @@ -3,6 +3,7 @@
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using Timer = System.Timers.Timer;
Expand Down Expand Up @@ -108,14 +109,31 @@ public async Task<(Uri, Version)> GetLatestRelease(bool isBeta)
var gitRelease = await GithubUtil.GetLatestRelease(repositoryName, userName, 0);
Version version = GithubUtil.GetVersion(gitRelease);

//download asset format: lively_setup_x86_full_vXXXX.exe, XXXX - 4 digit version no.
var gitUrl = await GithubUtil.GetAssetUrl("lively_setup_x86_full",
// Download latest installer file
// Format: lively_setup_ARCH_full_vXXXX.exe, XXXX - 4 digit version no and ARCH - x86, arm64
var arch = GetArchSetupString();
var gitUrl = await GithubUtil.GetAssetUrl($"lively_setup_{arch}_full",
gitRelease, repositoryName, userName);
Uri uri = new Uri(gitUrl);

//string changelog = gitRelease.Body;
var uri = new Uri(gitUrl);

return (uri, version);
}

private static string GetArchSetupString()
{
return RuntimeInformation.ProcessArchitecture switch
{
Architecture.X86 => "x86",
Architecture.X64 => "x64",
Architecture.Arm => throw new NotImplementedException(),
Architecture.Arm64 => "arm64",
Architecture.Wasm => throw new NotImplementedException(),
Architecture.S390x => throw new NotImplementedException(),
Architecture.LoongArch64 => throw new NotImplementedException(),
Architecture.Armv6 => throw new NotImplementedException(),
Architecture.Ppc64le => throw new NotImplementedException(),
_ => throw new NotImplementedException(),
};
}
}
}
69 changes: 28 additions & 41 deletions src/Lively/Lively/Factories/LivelyPropertyFactory.cs
Expand Up @@ -12,51 +12,38 @@ public class LivelyPropertyFactory : ILivelyPropertyFactory
{
public string CreateLivelyPropertyFolder(LibraryModel model, DisplayMonitor display, WallpaperArrangement arrangement, IUserSettingsService userSettings)
{
string propertyPath = null;
if (model.LivelyPropertyPath != null)
// Customisation not supported.
if (model.LivelyPropertyPath is null)
return null;

string propertyCopyPath = null;
var dataFolder = Path.Combine(userSettings.Settings.WallpaperDir, Constants.CommonPartialPaths.WallpaperSettingsDir);
try
{
//customisable wallpaper, livelyproperty.json is present.
var dataFolder = Path.Combine(userSettings.Settings.WallpaperDir, Constants.CommonPartialPaths.WallpaperSettingsDir);
try
{
//extract last digits of the Screen class DeviceName, eg: \\.\DISPLAY4 -> 4
var screenNumber = display.Index.ToString();
if (screenNumber != null)
{
//Create a directory with the wp foldername in SaveData/wpdata/, copy livelyproperties.json into this.
//Further modifications are done to the copy file.
string wpdataFolder = null;
switch (arrangement)
{
case WallpaperArrangement.per:
wpdataFolder = Path.Combine(dataFolder, new DirectoryInfo(model.LivelyInfoFolderPath).Name, screenNumber);
break;
case WallpaperArrangement.span:
wpdataFolder = Path.Combine(dataFolder, new DirectoryInfo(model.LivelyInfoFolderPath).Name, "span");
break;
case WallpaperArrangement.duplicate:
wpdataFolder = Path.Combine(dataFolder, new DirectoryInfo(model.LivelyInfoFolderPath).Name, "duplicate");
break;
}
Directory.CreateDirectory(wpdataFolder);
//copy the original file if not found..
propertyPath = Path.Combine(wpdataFolder, "LivelyProperties.json");
if (!File.Exists(propertyPath))
{
File.Copy(model.LivelyPropertyPath, propertyPath);
}
}
else
{
//todo: fallback, use the original file (restore feature disabled.)
}
}
catch
// Create a directory with the wallpaper foldername in SaveData/wpdata/, copy livelyproperties.json into this.
// Further modifications are done to the copy file.
string wallpaperDataDirectoryPath = null;
switch (arrangement)
{
//todo: fallback, use the original file (restore feature disabled.)
case WallpaperArrangement.per:
wallpaperDataDirectoryPath = Path.Combine(dataFolder, new DirectoryInfo(model.LivelyInfoFolderPath).Name, display.Index.ToString());
break;
case WallpaperArrangement.span:
wallpaperDataDirectoryPath = Path.Combine(dataFolder, new DirectoryInfo(model.LivelyInfoFolderPath).Name, "span");
break;
case WallpaperArrangement.duplicate:
wallpaperDataDirectoryPath = Path.Combine(dataFolder, new DirectoryInfo(model.LivelyInfoFolderPath).Name, "duplicate");
break;
}
Directory.CreateDirectory(wallpaperDataDirectoryPath);
// Copy the original file if not found..
propertyCopyPath = Path.Combine(wallpaperDataDirectoryPath, "LivelyProperties.json");
if (!File.Exists(propertyCopyPath))
File.Copy(model.LivelyPropertyPath, propertyCopyPath);
}
return propertyPath;
catch { /* Ignore, file related issue so consider wallpaper uncustomisable. */ }

return propertyCopyPath;
}
}
}

0 comments on commit 5ac3255

Please sign in to comment.