Skip to content

Commit c803372

Browse files
authored
Features/onedrive part 3 (#22)
* Extending the Retrieval logic Clean-up required but changes work :-) * More updates to sync, metrics etc * More user feedback * Starting the download files code * Initial version of the downlad code... still to be prove to work * Comple v1 of the download Fix bug where final token not saved * Rework Downloads and batch update dB * Add logging to keep the user updated on the dB saves * Wdding concurrent downloads * Update to create folder structure in dB before continuing * Adding metrics for file / folder downloads * Garbage in...Garbage out... Amongst other "improvements", earlier commits ment duplication of files / folders in the db whilst this ommit is RUBBISH, I am make as a stake in the ground where I can attempt to use the good bits, and bin the sh1t * NuGet updates
1 parent 29f1d6a commit c803372

25 files changed

+1501
-256
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"cSpell.words": [
33
"appsettings",
44
"Avalonia",
5-
"Kiota"
5+
"Kiota",
6+
"onedrive"
67
]
78
}

src/services/AStar.Dev.OneDrive.Client/AStar.Dev.OneDrive.Client.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
<ProjectReference Include="..\..\nuget-packages\AStar.Dev.Functional.Extensions\AStar.Dev.Functional.Extensions.csproj" />
1616
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="10.0.0" />
1717
<PackageReference Include="Microsoft.Graph" Version="5.97.0" />
18-
<PackageReference Include="Azure.Identity" Version="1.17.0" />
19-
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.0" />
20-
<PackageReference Include="Avalonia" Version="11.0.10" />
21-
<PackageReference Include="Avalonia.Desktop" Version="11.0.10" />
18+
<PackageReference Include="Azure.Identity" Version="1.17.1" />
19+
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
20+
<PackageReference Include="Avalonia" Version="11.3.9" />
21+
<PackageReference Include="Avalonia.Desktop" Version="11.3.9" />
2222
<!-- <PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.0.10" />-->
23-
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.10" />
23+
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.9" />
2424
<!-- <PackageReference Include="Avalonia.ReactiveUI" Version="11.0.10" />-->
25-
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.10" />
25+
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.3.9" />
2626
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
2727
<PackageReference Include="Serilog.Settings.Configuration" Version="7.0.0" />
2828
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />

src/services/AStar.Dev.OneDrive.Client/AppSettings.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ namespace AStar.Dev.OneDrive.Client;
22

33
public sealed class AppSettings
44
{
5-
public string ClientId { get; set; } = string.Empty;
6-
public string TenantId { get; set; } = "common"; // or your tenant
7-
public string ClientSecret { get; internal set; } = string.Empty;
8-
5+
// existing properties...
6+
public string ClientId { get; set; } = "";
7+
public string TenantId { get; set; } = "";
98
}
9+

src/services/AStar.Dev.OneDrive.Client/GraphClientFactory.cs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,12 @@ public static GraphServiceClient CreateGraphClient(
5555
return new GraphServiceClient(adapter);
5656
}
5757

58-
private sealed class PolicyHandler : DelegatingHandler
58+
private sealed class PolicyHandler(IAsyncPolicy<HttpResponseMessage> policy, Action<string>? logAction = null) : DelegatingHandler
5959
{
60-
private readonly IAsyncPolicy<HttpResponseMessage> _policy;
61-
private readonly Action<string>? _logAction;
62-
63-
public PolicyHandler(IAsyncPolicy<HttpResponseMessage> policy, Action<string>? logAction = null)
64-
{
65-
_policy = policy;
66-
_logAction = logAction;
67-
}
68-
6960
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
7061
{
71-
_logAction?.Invoke($"➡️ {request.Method} {request.RequestUri}");
72-
return _policy.ExecuteAsync(ct => base.SendAsync(request, ct), cancellationToken);
62+
logAction?.Invoke($"➡️ {request.Method} {request.RequestUri}");
63+
return policy.ExecuteAsync(ct => base.SendAsync(request, ct), cancellationToken);
7364
}
7465
}
7566
}

src/services/AStar.Dev.OneDrive.Client/Program.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using AStar.Dev.OneDrive.Client.Services;
2+
using AStar.Dev.OneDrive.Client.ViewModels;
23
using AStar.Dev.OneDrive.Client.Views;
34
using Avalonia;
45
using Microsoft.Extensions.Configuration;
@@ -76,9 +77,9 @@ public static IHostBuilder CreateHostBuilder(string[] args)
7677
?? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".config");
7778
}
7879

79-
var logDir = Path.Combine(baseDir, "AStar.Dev", "AStar.OneDrive.Client", "logs");
80+
var logDir = Path.Combine(baseDir, "astar-dev", "astar-dev-onedrive-client", "logs");
8081
_ = Directory.CreateDirectory(logDir);
81-
var logPath = Path.Combine(logDir, "AStar.OneDrive.Client-.log");
82+
var logPath = Path.Combine(logDir, "astar-dev-onedrive-client-.log");
8283

8384
_ = loggerConfig.WriteTo.File(logPath, rollingInterval: RollingInterval.Day, restrictedToMinimumLevel: LogEventLevel.Debug);
8485
}
@@ -95,6 +96,7 @@ public static IHostBuilder CreateHostBuilder(string[] args)
9596
_ = services.AddSingleton(appSettings);
9697
_ = services.AddSingleton<ILoginService, LoginService>();
9798
_ = services.AddTransient<MainWindowViewModel>();
99+
_ = services.AddTransient<UserSettings>();
98100
_ = services.AddTransient<OneDriveService>();
99101
_ = services.AddSingleton<UserSettingsService>();
100102
_ = services.AddTransient<MainWindow>();

0 commit comments

Comments
 (0)