Skip to content
Snippets Groups Projects
Commit a990c0fd authored by Niko Ehrenfeuchter's avatar Niko Ehrenfeuchter :keyboard:
Browse files

Try to create incoming and managed directory trees if missing.

Check on startup if they exist, try to create them otherwise. Remove the
corresponding section from the installer script.

Refers to issue #7.
parent d71a35b1
No related branches found
No related tags found
No related merge requests found
......@@ -144,18 +144,23 @@ namespace AutoTx
@" and a backslash, e.g. 'D:\'!");
configInvalid = true;
}
// IncomingDirectory
// spooling directories: IncomingDirectory + ManagedDirectory
if (_config.IncomingDirectory.StartsWith(@"\")) {
writeLog("ERROR: IncomingDirectory must not start with a backslash!");
configInvalid = true;
}
_incomingPath = Path.Combine(_config.SourceDrive, _config.IncomingDirectory);
// ManagedDirectory
if (_config.ManagedDirectory.StartsWith(@"\")) {
writeLog("ERROR: ManagedDirectory must not start with a backslash!");
configInvalid = true;
}
_incomingPath = Path.Combine(_config.SourceDrive, _config.IncomingDirectory);
_managedPath = Path.Combine(_config.SourceDrive, _config.ManagedDirectory);
if (CheckSpoolingDirectories() == false) {
writeLog("ERROR checking spooling directories (incoming / managed)!");
configInvalid = true;
}
if (_config.ServiceTimer < 1000) {
writeLog("ERROR: ServiceTimer must not be smaller than 1000 ms!");
configInvalid = true;
......@@ -833,6 +838,19 @@ namespace AutoTx
return CreateNewDirectory(path, false) == path;
}
/// <summary>
/// Ensure the required spooling directories (managed/incoming) exist.
/// </summary>
/// <returns>True if all dirs exist or were created successfully.</returns>
private bool CheckSpoolingDirectories() {
var retval = CheckForDirectory(_incomingPath);
retval &= CheckForDirectory(_managedPath);
retval &= CheckForDirectory(Path.Combine(_managedPath, "PROCESSING"));
retval &= CheckForDirectory(Path.Combine(_managedPath, "DONE"));
retval &= CheckForDirectory(Path.Combine(_managedPath, "UNMATCHED"));
return retval;
}
#endregion
}
......
......@@ -112,13 +112,6 @@ function Uninstall-FileCopyService {
}
function Create-Directories {
$foo = New-Item -ItemType Container -Force -Path "$IncomingDir"
$foo = New-Item -ItemType Container -Force -Path "$($ManagedDir)\DONE"
$foo = New-Item -ItemType Container -Force -Path "$($ManagedDir)\PROCESSING"
$foo = New-Item -ItemType Container -Force -Path "$($ManagedDir)\UNMATCHED"
}
$LocalConfiguration = ".\ScriptsConfig.ps1"
if (Test-Path $LocalConfiguration) {
......@@ -136,12 +129,10 @@ try {
Write-Host "Service $($ServiceName) already installed, updating."
Stop-MyService
Copy-ServiceFiles
Create-Directories
}
catch {
Copy-ServiceFiles
Install-Service
Create-Directories
}
Start-MyService
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment