From ddee94d70ca3432534699f5486e34a6d1d93dca0 Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch> Date: Mon, 18 Dec 2017 09:23:13 +0100 Subject: [PATCH] Move processing of queued dirs into separate method. --- AutoTx/AutoTx.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/AutoTx/AutoTx.cs b/AutoTx/AutoTx.cs index a76f9f1..b27d729 100644 --- a/AutoTx/AutoTx.cs +++ b/AutoTx/AutoTx.cs @@ -610,17 +610,27 @@ namespace AutoTx // next check if there is a transfer that has to be resumed: ResumeInterruptedTransfer(); - // check if any of the above calls changed the transfer state: + // check the queueing location and dispatch new transfers: + ProcessQueuedDirectories(); + } + + /// <summary> + /// Process directories in the queueing location, dispatching new transfers if applicable. + /// </summary> + private void ProcessQueuedDirectories() { + // only proceed when in a valid state: if (_transferState != TxState.Stopped) return; - // select next directory from "processing" for transfer: + // check the "processing" location for directories: var processingDir = Path.Combine(_managedPath, "PROCESSING"); var queued = new DirectoryInfo(processingDir).GetDirectories(); if (queued.Length == 0) return; var subdirs = queued[0].GetDirectories(); + // having no subdirectories should not happen in theory - in practice it could e.g. if + // an admin is moving around stuff while the service is operating, so better be safe: if (subdirs.Length == 0) { writeLog("WARNING: empty processing directory found: " + queued[0].Name); try { @@ -632,6 +642,8 @@ namespace AutoTx } return; } + + // dispatch the next directory from "processing" for transfer: try { StartTransfer(subdirs[0].FullName); } -- GitLab