Skip to content

Commit

Permalink
get once and stop files from the config.
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinJump committed Jan 9, 2025
1 parent bc662f6 commit 3164dbb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
12 changes: 12 additions & 0 deletions uSync.BackOffice/Configuration/uSyncSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ public class uSyncSettings
/// </summary>
public bool LockRoot { get; set; } = true;

/// <summary>
/// location of the stop file (relative to the uSync folder)
/// </summary>
[DefaultValue("usync.stop")]
public string StopFile { get; set; } = "usync.stop";

/// <summary>
/// location of the once file (relative to the uSync folder)
/// </summary>
[DefaultValue("usync.once")]
public string OnceFile { get; set; } = "usync.once";

/// <summary>
/// lock specific types at root so they can't be changed in child sites.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private void InituSync()
}
else
{
_logger.LogInformation("Startup Import blocked by usync.stop file");
_logger.LogInformation("Startup Import blocked by {stop} file", _uSyncConfig.Settings.StopFile);
}
}
}
Expand Down Expand Up @@ -151,18 +151,18 @@ private bool HasSyncFolders()
/// does the uSync folder contain a uSync.stop file (which would mean we would not process anything at startup)
/// </summary>
private bool HasStopFile(string folder)
=> _syncFileService.FileExists($"{folder}/usync.stop");
=> _syncFileService.FileExists($"{folder}/{_uSyncConfig.Settings.StopFile}");

/// <summary>
/// Process the once file (if it exists we rename it to usync.stop).
/// </summary>
private void ProcessOnceFile(string folder)
{
if (_syncFileService.FileExists($"{folder}/usync.once"))
if (_syncFileService.FileExists($"{folder}/{_uSyncConfig.Settings.OnceFile}"))
{
_syncFileService.DeleteFile($"{folder}/usync.once");
_syncFileService.SaveFile($"{folder}/usync.stop", "uSync Stop file, prevents startup import");
_logger.LogInformation("usync.once file replaced by usync.stop file");
_syncFileService.DeleteFile($"{folder}/{_uSyncConfig.Settings.OnceFile}");
_syncFileService.SaveFile($"{folder}/{_uSyncConfig.Settings.StopFile}", "uSync Stop file, prevents startup import");
_logger.LogInformation($"{_uSyncConfig.Settings.OnceFile} file replaced by {_uSyncConfig.Settings.StopFile} file");
}
}

Expand Down

0 comments on commit 3164dbb

Please sign in to comment.