Skip to content

Commit 6380d96

Browse files
Merge branch 'master' into feat/misc-improvements-1508
2 parents 291fd2b + 564e0e5 commit 6380d96

File tree

25 files changed

+2142
-75
lines changed

25 files changed

+2142
-75
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Trigger Azure Pipeline on PR Commit
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
types: [synchronize, opened]
8+
paths:
9+
- 'src/ByteSync.Common/**'
10+
- 'src/ByteSync.Functions/**'
11+
- 'src/ByteSync.ServerCommon/**'
12+
- 'tests/ByteSync.Common.Tests/**'
13+
- 'tests/ByteSync.Functions.IntegrationTests/**'
14+
- 'tests/ByteSync.Functions.UnitTests/**'
15+
- 'tests/ByteSync.ServerCommon.Tests/**'
16+
- 'tests/ByteSync.TestsCommon/**'
17+
18+
push:
19+
branches:
20+
- master
21+
paths:
22+
- 'src/ByteSync.Common/**'
23+
- 'src/ByteSync.Functions/**'
24+
- 'src/ByteSync.ServerCommon/**'
25+
- 'tests/ByteSync.Common.Tests/**'
26+
- 'tests/ByteSync.Functions.IntegrationTests/**'
27+
- 'tests/ByteSync.Functions.UnitTests/**'
28+
- 'tests/ByteSync.ServerCommon.Tests/**'
29+
- 'tests/ByteSync.TestsCommon/**'
30+
31+
workflow_dispatch:
32+
33+
permissions:
34+
contents: read
35+
actions: read
36+
37+
jobs:
38+
trigger-azure-pipeline:
39+
if: ${{ secrets.AZURE_DEVOPS_TOKEN != '' && vars.AZURE_DEVOPS_PROJECT_URL != '' && vars.AZURE_DEVOPS_PIPELINE != '' }}
40+
runs-on: ubuntu-latest
41+
steps:
42+
43+
- name: Extract branch name
44+
shell: bash
45+
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_ENV
46+
id: extract_branch
47+
48+
- name: Get Pipeline ID by Name
49+
id: get-pipeline-id
50+
run: |
51+
response=$(curl -X GET -H "Authorization: Bearer ${{ secrets.AZURE_DEVOPS_TOKEN }}" \
52+
"${{ vars.AZURE_DEVOPS_PROJECT_URL }}/_apis/pipelines?api-version=6.0-preview.1")
53+
pipelineId=$(echo $response | jq -r '.value[] | select(.name=="${{ vars.AZURE_DEVOPS_PIPELINE }}") | .id')
54+
if [ -z "$pipelineId" ]; then
55+
echo "Error: Pipeline not found" >&2
56+
exit 1
57+
fi
58+
echo "pipelineId=$pipelineId" >> $GITHUB_ENV
59+
60+
- name: Trigger Azure Pipeline
61+
id: trigger-pipeline
62+
run: |
63+
response=$(curl -X POST -H "Authorization: Bearer ${{ secrets.AZURE_DEVOPS_TOKEN }}" \
64+
-H "Content-Type: application/json" \
65+
-d "{\"resources\": {}, \"variables\": {
66+
\"github-branch\": {
67+
\"value\": \"${branch}\"
68+
}
69+
}}" \
70+
"${{ vars.AZURE_DEVOPS_PROJECT_URL }}/_apis/pipelines/${{ env.pipelineId }}/runs?api-version=6.0-preview.1")
71+
echo "runId=$(echo $response | jq -r '.id')" >> $GITHUB_ENV
72+
echo "Response: $response"
73+
74+
- name: Wait for Pipeline to Complete
75+
id: wait-pipeline
76+
run: |
77+
status="inProgress"
78+
while [ "$status" == "inProgress" ]; do
79+
sleep 30
80+
response=$(curl -X GET -H "Authorization: Bearer ${{ secrets.AZURE_DEVOPS_TOKEN }}" \
81+
"${{ vars.AZURE_DEVOPS_PROJECT_URL }}/_apis/pipelines/${{ env.pipelineId }}/runs/${{ env.runId }}?api-version=6.0-preview.1")
82+
status=$(echo $response | jq -r '.state')
83+
done
84+
85+
result=$(echo $response | jq -r '.result')
86+
echo "result=$result" >> $GITHUB_ENV
87+
88+
- name: Check Pipeline Result
89+
if: env.result != 'succeeded'
90+
run: exit 1

src/ByteSync.Client/Assets/Resources/Resources.fr.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,9 @@ Veuillez interrompre l'inventaire ou la synchronisation au préalable.</value>
943943
<data name="SynchronizationMain_AbortSynchronization_Message" xml:space="preserve">
944944
<value>Voulez abandonner la synchronisation en cours ?</value>
945945
</data>
946+
<data name="SynchronizationMain_AbortSynchronization" xml:space="preserve">
947+
<value>ABANDONNER</value>
948+
</data>
946949
<data name="General_or" xml:space="preserve">
947950
<value>ou</value>
948951
</data>

src/ByteSync.Client/Assets/Resources/Resources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,9 @@ Please stop the inventory or synchronization first.</value>
952952
<data name="SynchronizationMain_AbortSynchronization_Message" xml:space="preserve">
953953
<value>Want to abort the current synchronization?</value>
954954
</data>
955+
<data name="SynchronizationMain_AbortSynchronization" xml:space="preserve">
956+
<value>ABORT</value>
957+
</data>
955958
<data name="General_or" xml:space="preserve">
956959
<value>or</value>
957960
</data>

src/ByteSync.Client/Business/Synchronizations/SynchronizationProcessData.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Reactive.Subjects;
2+
using System.Threading;
23
using ByteSync.Common.Business.Synchronizations;
34

45
namespace ByteSync.Business.Synchronizations;
@@ -16,6 +17,8 @@ public SynchronizationProcessData()
1617

1718
SynchronizationProgress = new BehaviorSubject<SynchronizationProgress?>(null);
1819

20+
CancellationTokenSource = new CancellationTokenSource();
21+
1922
Reset();
2023
}
2124

@@ -30,6 +33,8 @@ public SynchronizationProcessData()
3033

3134
public long TotalVolumeToProcess { get; set; }
3235
public long TotalActionsToProcess { get; set; }
36+
37+
public CancellationTokenSource CancellationTokenSource { get; private set; }
3338

3439
public Task<bool> IsSynchronizationEnd()
3540
{
@@ -54,5 +59,17 @@ public void Reset()
5459
SynchronizationDataTransmitted.OnNext(false);
5560

5661
SynchronizationProgress.OnNext(null);
62+
63+
CancellationTokenSource = new CancellationTokenSource();
64+
}
65+
66+
public void RequestSynchronizationAbort()
67+
{
68+
CancellationTokenSource.Cancel();
69+
var synchronizationAbortRequest = new SynchronizationAbortRequest
70+
{
71+
RequestedOn = DateTimeOffset.Now
72+
};
73+
SynchronizationAbortRequest.OnNext(synchronizationAbortRequest);
5774
}
5875
}
Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,48 @@
11
using System.Reactive.Linq;
2-
using System.Threading.Tasks;
2+
using System.Threading;
33

44
namespace ByteSync.Helpers;
55

66
public static class ReactiveUtils
77
{
8+
public static async Task WaitUntilTrue(this IObservable<bool> subject, CancellationToken cancellationToken = default)
9+
{
10+
await subject.WaitUntilTrue(TimeSpan.FromMilliseconds(-1), cancellationToken);
11+
}
12+
813
public static async Task WaitUntilTrue(this IObservable<bool> subject, TimeSpan? timeout = null)
914
{
1015
var observable = subject.FirstAsync(x => x);
1116

12-
if (timeout.HasValue)
17+
// Only apply timeout if it's a positive value (null or negative means infinite timeout)
18+
if (timeout.HasValue && timeout.Value.TotalMilliseconds > 0)
1319
{
1420
observable = observable.Timeout(timeout.Value);
1521
}
1622

1723
await observable;
1824
}
25+
26+
public static async Task WaitUntilTrue(this IObservable<bool> subject, TimeSpan timeout, CancellationToken cancellationToken)
27+
{
28+
var observable = subject.FirstAsync(x => x);
29+
30+
// Only apply timeout if it's a positive value (negative means infinite timeout)
31+
if (timeout.TotalMilliseconds > 0)
32+
{
33+
observable = observable.Timeout(timeout);
34+
}
35+
36+
// Use a TaskCompletionSource to handle cancellation properly
37+
var tcs = new TaskCompletionSource<bool>();
38+
39+
using var subscription = observable.Subscribe(
40+
result => tcs.TrySetResult(result),
41+
error => tcs.TrySetException(error)
42+
);
43+
44+
using var cancellationRegistration = cancellationToken.Register(() => tcs.TrySetCanceled());
45+
46+
await tcs.Task;
47+
}
1948
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
using System.Threading.Tasks;
1+
using System.Threading;
22
using ByteSync.Business.Actions.Shared;
33

44
namespace ByteSync.Interfaces.Controls.Synchronizations;
55

66
public interface ISynchronizationActionHandler
77
{
8-
Task RunSynchronizationAction(SharedActionsGroup sharedActionsGroup);
8+
Task RunSynchronizationAction(SharedActionsGroup sharedActionsGroup, CancellationToken cancellationToken = default);
99

10-
Task RunPendingSynchronizationActions();
10+
Task RunPendingSynchronizationActions(CancellationToken cancellationToken = default);
1111
}

src/ByteSync.Client/Services/Communications/PushReceivers/DataNodePushReceiver.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Reactive.Linq;
2-
using ByteSync.Business.DataNodes;
32
using ByteSync.Interfaces.Communications;
43
using ByteSync.Interfaces.Controls.Communications.SignalR;
54
using ByteSync.Interfaces.Controls.Encryptions;

src/ByteSync.Client/Services/Communications/PushReceivers/DataSourcePushReceiver.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using ByteSync.Interfaces.Controls.Communications.SignalR;
44
using ByteSync.Interfaces.Controls.Encryptions;
55
using ByteSync.Interfaces.Controls.Inventories;
6-
using ByteSync.Interfaces.Repositories;
76
using ByteSync.Interfaces.Services.Sessions;
87

98
namespace ByteSync.Services.Communications.PushReceivers;

src/ByteSync.Client/Services/Communications/PushReceivers/SessionConnectionPushReceiver.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using ByteSync.Interfaces.Communications;
22
using ByteSync.Interfaces.Controls.Communications.SignalR;
3-
using ByteSync.Interfaces.Services.Sessions.Connecting;
43
using ByteSync.Interfaces.Services.Sessions.Connecting.Joining;
54
using ByteSync.Interfaces.Services.Sessions.Connecting.Validating;
65

src/ByteSync.Client/Services/Communications/PushReceivers/SessionMemberPushReceiver.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@
22
using ByteSync.Interfaces.Controls.Communications.SignalR;
33
using ByteSync.Interfaces.Repositories;
44
using System.Reactive.Linq;
5-
using ByteSync.Business.Inventories;
65
using ByteSync.Business.SessionMembers;
76
using ByteSync.Common.Business.Sessions;
8-
using ByteSync.Common.Helpers;
9-
using ByteSync.Interfaces.Controls.Encryptions;
107
using ByteSync.Interfaces.Controls.Inventories;
118
using ByteSync.Interfaces.Services.Sessions;
129

0 commit comments

Comments
 (0)