Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion backend/FwHeadless/Services/SyncHostedService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@
result.CrdtChanges,
result.FwdataChanges);

await crdtSyncService.SyncHarmonyProject();
if (result.FwdataChanges == 0)
{
logger.LogInformation("No Send/Receive needed after CRDT sync as no FW changes were made by the sync");
Expand All @@ -208,6 +207,24 @@
logger.LogInformation("Send/Receive result after CRDT sync: {Output}", srResult2.Output);
}
}

//We only want to regenerate the snapshot if we know the changes applied to fwdata were successfully pushed.
//Otherwise, the changes might have been rolled back.
if (result.CrdtChanges > 0)
{
logger.LogInformation("Regenerating project snapshot to include crdt changes");
//note we are now using the crdt API, this avoids issues where some data isn't synced yet
//later when we add the ability to sync that data we need the snapshot to reflect the synced state, not what was in the FW project
//related to https://github.com/sillsdev/languageforge-lexbox/issues/1912
await syncService.RegenerateProjectSnapshot(miniLcmApi, fwdataApi.Project);
}
else
{
logger.LogInformation("Skipping regenerating project snapshot, because there were no crdt changes"):

Check failure on line 223 in backend/FwHeadless/Services/SyncHostedService.cs

View workflow job for this annotation

GitHub Actions / Build API / publish-api

} expected

Check failure on line 223 in backend/FwHeadless/Services/SyncHostedService.cs

View workflow job for this annotation

GitHub Actions / Build API / publish-api

; expected

Check failure on line 223 in backend/FwHeadless/Services/SyncHostedService.cs

View workflow job for this annotation

GitHub Actions / Build API / publish-api

} expected

Check failure on line 223 in backend/FwHeadless/Services/SyncHostedService.cs

View workflow job for this annotation

GitHub Actions / Build API / publish-api

; expected

Check failure on line 223 in backend/FwHeadless/Services/SyncHostedService.cs

View workflow job for this annotation

GitHub Actions / Build FwHeadless / publish-fw-headless

} expected

Check failure on line 223 in backend/FwHeadless/Services/SyncHostedService.cs

View workflow job for this annotation

GitHub Actions / Build FwHeadless / publish-fw-headless

; expected

Check failure on line 223 in backend/FwHeadless/Services/SyncHostedService.cs

View workflow job for this annotation

GitHub Actions / Build FwHeadless / publish-fw-headless

} expected

Check failure on line 223 in backend/FwHeadless/Services/SyncHostedService.cs

View workflow job for this annotation

GitHub Actions / Build FwHeadless / publish-fw-headless

; expected
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Fix syntax error: replace colon with semicolon.

The line has a colon : instead of semicolon ; at the end, causing a compilation failure.

Apply this diff:

-            logger.LogInformation("Skipping regenerating project snapshot, because there were no crdt changes"):
+            logger.LogInformation("Skipping regenerating project snapshot, because there were no crdt changes");
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
logger.LogInformation("Skipping regenerating project snapshot, because there were no crdt changes"):
logger.LogInformation("Skipping regenerating project snapshot, because there were no crdt changes");
🧰 Tools
🪛 GitHub Actions: Develop FwHeadless CI/CD

[error] 223-223: CS1002: ; expected. Command: dotnet build backend/FwHeadless/FwHeadless.csproj

🪛 GitHub Check: Build FwHeadless / publish-fw-headless

[failure] 223-223:
} expected


[failure] 223-223:
; expected


[failure] 223-223:
} expected


[failure] 223-223:
; expected

🤖 Prompt for AI Agents
In backend/FwHeadless/Services/SyncHostedService.cs around line 223, the
statement ends with a colon instead of a semicolon causing a compile error;
replace the trailing ':' with ';' so the logger.LogInformation(...) statement
terminates correctly.

}

await crdtSyncService.SyncHarmonyProject();

activity?.SetStatus(ActivityStatusCode.Ok, "Sync finished");
return new SyncJobResult(result);
}
Expand Down
2 changes: 2 additions & 0 deletions backend/FwLite/FwLiteProjectSync.Tests/CrdtRepairTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@

// act
await SyncService.Sync(CrdtApi, FwDataApi);
await SyncService.RegenerateProjectSnapshot(CrdtApi, FwDataApi.Project);

// assert - the fwdata ID is now used everywhere
var updatedFwEntry = await FwDataApi.GetEntry(crdtEntry.Id);
Expand Down Expand Up @@ -156,6 +157,7 @@

// act
await SyncService.Sync(CrdtApi, FwDataApi);
await SyncService.RegenerateProjectSnapshot(CrdtApi, FwDataApi.Project);

// assert - the fwdata ID is now used everywhere
var updatedFwEntry = await FwDataApi.GetEntry(crdtEntry.Id);
Expand Down Expand Up @@ -323,7 +325,7 @@

// assert - the default ID was used in the new fw translation
var fwEntry = await FwDataApi.GetEntry(crdtEntry.Id);
fwEntry.Should().NotBeNull();

Check failure on line 328 in backend/FwLite/FwLiteProjectSync.Tests/CrdtRepairTests.cs

View workflow job for this annotation

GitHub Actions / Build FW Lite and run tests

FwLiteProjectSync.Tests.CrdtRepairTests.CrdtEntryMissingTranslationId_NewCrdtEntry_FullSync

Expected fwEntry not to be <null>.
var exampleSentence = crdtEntry.SingleExampleSentence();
fwEntry.SingleTranslation().Id.Should().Be(exampleSentence.DefaultFirstTranslationId);
}
Expand Down
1 change: 1 addition & 0 deletions backend/FwLite/FwLiteProjectSync.Tests/Sena3SyncTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ public async Task LiveSena3Sync()

// act
var result = await _syncService.Sync(liveCrdtApi, _fwDataApi);
await _syncService.RegenerateProjectSnapshot(liveCrdtApi, _fwDataApi.Project);

// assert
var fwHeadlessSnapshot = await _syncService.GetProjectSnapshot(_project.FwDataProject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,6 @@ public async Task<SyncResult> Sync(IMiniLcmApi crdtApi, FwDataMiniLcmApi fwdataA

SyncResult result = await Sync(crdtApi, fwdataApi, dryRun, fwdataApi.EntryCount, projectSnapshot);
fwdataApi.Save();

if (!dryRun)
{
//note we are now using the crdt API, this avoids issues where some data isn't synced yet
//later when we add the ability to sync that data we need the snapshot to reflect the synced state, not what was in the FW project
//related to https://github.com/sillsdev/languageforge-lexbox/issues/1912
await RegenerateProjectSnapshot(crdtApi, fwdataApi.Project);
}
return result;
}

Expand Down
Loading