Skip to content

Commit

Permalink
Create Inbox/Outbox directories before using
Browse files Browse the repository at this point in the history
if they don't exist. This prevents unnecessary exceptions when starting up the service

Fixes #5
  • Loading branch information
wgnf committed Oct 24, 2021
1 parent 322f460 commit 495ca62
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Attached to the Release you'll find a `CsvProc9000-vX_X_X.zip` which contains:
Before running `CreateService.bat` you should make sure that your configuration is the way you want it to be. If there are any issues with starting the service, check out the log-file that is generated in the location where the `CsvProc9000.exe` is, in the folder `logs`. Common issues are:

- Forgot to configure the Inbox/Outbox folders
- Inbox folder does not exist

## 🖱️ Update

Expand Down
1 change: 0 additions & 1 deletion src/CsvProc9000/CsvProc9000.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<UserSecretsId>dotnet-CsvProc9000-055DDDC9-859F-42E2-A255-DB243F7D73A6</UserSecretsId>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/CsvProc9000/Processors/CsvProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private async Task SaveResultAsync(IFileSystemInfo file, CsvFile csvFile)

_logger.LogInformation("Processor: Saving result to {Destination}...", destinationFileName);

if (_fileSystem.Directory.Exists(_processorOptions.Outbox))
if (!_fileSystem.Directory.Exists(_processorOptions.Outbox))
_fileSystem.Directory.CreateDirectory(_processorOptions.Outbox);

await _saveCsvFile.SaveToAsync(csvFile, destinationFileName, _processorOptions.OutboxDelimiter);
Expand Down Expand Up @@ -127,4 +127,4 @@ private bool IsFileLocked(IFileSystemInfo file)
}
}
}
}
}
5 changes: 4 additions & 1 deletion src/CsvProc9000/Workers/CsvWatcherWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public CsvWatcherWorker(

protected override Task ExecuteAsync(CancellationToken stoppingToken)
{
if (!_fileSystem.Directory.Exists(_processorOptions.Inbox))
_fileSystem.Directory.CreateDirectory(_processorOptions.Inbox);

_logger.LogInformation("Watcher: Starting to watch for files in {Target}...", _processorOptions.Inbox);
_fileSystemWatcher.EnableRaisingEvents = true;

Expand Down Expand Up @@ -80,4 +83,4 @@ private void OnFileCreated(object sender, FileSystemEventArgs eventArgs)
_csvProcessor.ProcessAsync(file).WaitAndUnwrapException();
}
}
}
}

0 comments on commit 495ca62

Please sign in to comment.