From 6a44ade8d6acee18cccfb10b7cfaaa2423cf8a80 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 15 Jan 2026 10:24:48 +0000 Subject: [PATCH 1/4] Initial plan From 9531324212e52f872b0d18cfc84992b9f0a81853 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 15 Jan 2026 10:29:12 +0000 Subject: [PATCH 2/4] Add IgnoreStopIfOnceExists setting to support write-only deployments Co-authored-by: KevinJump <431231+KevinJump@users.noreply.github.com> --- .../appsettings-schema.usync.json | 5 +++++ uSync.BackOffice/Configuration/uSyncSettings.cs | 6 ++++++ .../uSyncApplicationStartingHandler.cs | 15 +++++++++++++-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/uSync.BackOffice.Targets/appsettings-schema.usync.json b/uSync.BackOffice.Targets/appsettings-schema.usync.json index 8c23c4434..56aae1feb 100644 --- a/uSync.BackOffice.Targets/appsettings-schema.usync.json +++ b/uSync.BackOffice.Targets/appsettings-schema.usync.json @@ -84,6 +84,11 @@ "description": "location of the once file (relative to the uSync folder)\n ", "default": "usync.once" }, + "IgnoreStopIfOnceExists": { + "type": "boolean", + "description": "When enabled, the presence of a once file will override the stop file, allowing import to proceed\n ", + "default": false + }, "LockRootTypes": { "type": "array", "description": "lock specific types at root so they can't be changed in child sites. \n ", diff --git a/uSync.BackOffice/Configuration/uSyncSettings.cs b/uSync.BackOffice/Configuration/uSyncSettings.cs index 08cc1bc62..d5661fc68 100644 --- a/uSync.BackOffice/Configuration/uSyncSettings.cs +++ b/uSync.BackOffice/Configuration/uSyncSettings.cs @@ -50,6 +50,12 @@ public class uSyncSettings [DefaultValue("usync.once")] public string OnceFile { get; set; } = "usync.once"; + /// + /// When enabled, the presence of a once file will override the stop file, allowing import to proceed + /// + [DefaultValue(false)] + public bool IgnoreStopIfOnceExists { get; set; } = false; + /// /// lock specific types at root so they can't be changed in child sites. /// diff --git a/uSync.BackOffice/Notifications/uSyncApplicationStartingHandler.cs b/uSync.BackOffice/Notifications/uSyncApplicationStartingHandler.cs index dac1d24a9..8d01b1243 100644 --- a/uSync.BackOffice/Notifications/uSyncApplicationStartingHandler.cs +++ b/uSync.BackOffice/Notifications/uSyncApplicationStartingHandler.cs @@ -129,14 +129,19 @@ private async Task InituSyncAsync() { _logger.LogInformation("uSync: Running Import at startup {group}", _uSyncConfig.Settings.ImportAtStartup); - if (!HasStopFile(_uSyncConfig.GetWorkingFolder())) + var workingFolder = _uSyncConfig.GetWorkingFolder(); + var hasStopFile = HasStopFile(workingFolder); + var hasOnceFile = HasOnceFile(workingFolder); + var shouldImport = !hasStopFile || (_uSyncConfig.Settings.IgnoreStopIfOnceExists && hasOnceFile); + + if (shouldImport) { await _uSyncService.StartupImportAsync(_uSyncConfig.GetFolders(), false, new SyncHandlerOptions { Group = _uSyncConfig.Settings.ImportAtStartup }); - await ProcessOnceFileAsync(_uSyncConfig.GetWorkingFolder()); + await ProcessOnceFileAsync(workingFolder); } else { @@ -178,6 +183,12 @@ private bool HasSyncFolders() private bool HasStopFile(string folder) => _syncFileService.FileExists($"{folder}/{_uSyncConfig.Settings.StopFile}"); + /// + /// does the uSync folder contain a uSync.once file + /// + private bool HasOnceFile(string folder) + => _syncFileService.FileExists($"{folder}/{_uSyncConfig.Settings.OnceFile}"); + /// /// Process the once file (if it exists we rename it to usync.stop). /// From 11498d53bcd4abfe2f87199b924d1949b6cc72e8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 15 Jan 2026 10:30:29 +0000 Subject: [PATCH 3/4] Refactor: improve readability of import decision logic Co-authored-by: KevinJump <431231+KevinJump@users.noreply.github.com> --- .../uSyncApplicationStartingHandler.cs | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/uSync.BackOffice/Notifications/uSyncApplicationStartingHandler.cs b/uSync.BackOffice/Notifications/uSyncApplicationStartingHandler.cs index 8d01b1243..3383875a0 100644 --- a/uSync.BackOffice/Notifications/uSyncApplicationStartingHandler.cs +++ b/uSync.BackOffice/Notifications/uSyncApplicationStartingHandler.cs @@ -132,9 +132,8 @@ private async Task InituSyncAsync() var workingFolder = _uSyncConfig.GetWorkingFolder(); var hasStopFile = HasStopFile(workingFolder); var hasOnceFile = HasOnceFile(workingFolder); - var shouldImport = !hasStopFile || (_uSyncConfig.Settings.IgnoreStopIfOnceExists && hasOnceFile); - if (shouldImport) + if (ShouldProceedWithImport(hasStopFile, hasOnceFile)) { await _uSyncService.StartupImportAsync(_uSyncConfig.GetFolders(), false, new SyncHandlerOptions { @@ -184,11 +183,26 @@ private bool HasStopFile(string folder) => _syncFileService.FileExists($"{folder}/{_uSyncConfig.Settings.StopFile}"); /// - /// does the uSync folder contain a uSync.once file + /// Does the uSync folder contain a uSync.once file? /// private bool HasOnceFile(string folder) => _syncFileService.FileExists($"{folder}/{_uSyncConfig.Settings.OnceFile}"); + /// + /// Determines if the import should proceed based on the presence of stop and once files. + /// + private bool ShouldProceedWithImport(bool hasStopFile, bool hasOnceFile) + { + // If there's no stop file, proceed with import + if (!hasStopFile) return true; + + // If stop file exists and IgnoreStopIfOnceExists is enabled, check for once file + if (_uSyncConfig.Settings.IgnoreStopIfOnceExists && hasOnceFile) return true; + + // Otherwise, stop file blocks the import + return false; + } + /// /// Process the once file (if it exists we rename it to usync.stop). /// From ea8f6488c6aacd34a0cf73a9d142c8bc3d60380b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 15 Jan 2026 10:31:13 +0000 Subject: [PATCH 4/4] Add XML documentation for method parameters Co-authored-by: KevinJump <431231+KevinJump@users.noreply.github.com> --- .../Notifications/uSyncApplicationStartingHandler.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/uSync.BackOffice/Notifications/uSyncApplicationStartingHandler.cs b/uSync.BackOffice/Notifications/uSyncApplicationStartingHandler.cs index 3383875a0..267a292aa 100644 --- a/uSync.BackOffice/Notifications/uSyncApplicationStartingHandler.cs +++ b/uSync.BackOffice/Notifications/uSyncApplicationStartingHandler.cs @@ -191,6 +191,9 @@ private bool HasOnceFile(string folder) /// /// Determines if the import should proceed based on the presence of stop and once files. /// + /// Whether a stop file exists in the working folder + /// Whether a once file exists in the working folder + /// True if import should proceed, false otherwise private bool ShouldProceedWithImport(bool hasStopFile, bool hasOnceFile) { // If there's no stop file, proceed with import