From a651bafb392d0afde9dea8897f5d88e3033c8dde Mon Sep 17 00:00:00 2001
From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch>
Date: Fri, 2 Feb 2018 15:36:54 +0100
Subject: [PATCH] Some comments and logging changes in RoboCommand.

Refers to #26
---
 ATxService/RoboCommand.cs | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/ATxService/RoboCommand.cs b/ATxService/RoboCommand.cs
index c8f30d8..ecd8a92 100644
--- a/ATxService/RoboCommand.cs
+++ b/ATxService/RoboCommand.cs
@@ -75,6 +75,7 @@ namespace ATxService
                 _roboCommand.Start();
                 Log.Info("Transfer started, total size: {0}",
                     Conv.BytesToString(_status.CurrentTransferSize));
+                Log.Debug("RoboCopy command options: {0}", _roboCommand.CommandOptions);
             }
             catch (ManagementException ex) {
                 Log.Error("Error in StartTransfer(): {0}", ex.Message);
@@ -113,10 +114,19 @@ namespace ATxService
 
         /// <summary>
         /// RoboSharp OnFileProcessed callback handler.
+        /// 
+        /// NOTE: the handler is called on any NEW message produced by RoboCopy, in particular this
+        /// also means that a "new file" event is triggered when the transfer of a new file is
+        /// about TO START! Therefore the "OnFileProcessed" name is slightly misleading.
         /// </summary>
         private void RsFileProcessed(object sender, FileProcessedEventArgs e) {
             try {
                 var processed = e.ProcessedFile;
+
+                Log.Trace("RsFileProcessed (OnFileProcessed handler) triggered:  " +
+                    "Class [{1}]  -  Size [{2}]  -  Name [{0}]",
+                    e.ProcessedFile.Name, e.ProcessedFile.FileClass, e.ProcessedFile.Size);
+
                 // WARNING: RoboSharp doesn't seem to offer a culture invariant representation
                 // of the FileClass, so this might fail in non-english environments:
                 if (processed.FileClass.ToLower().Equals("new file")) {
@@ -149,6 +159,7 @@ namespace ATxService
         /// Print a log message if the progress has changed for more than 20%.
         /// </summary>
         private void RsProgressChanged(object sender, CopyProgressEventArgs e) {
+            // e.CurrentFileProgress has the current progress in percent
             // report progress in steps of 20:
             var progress = ((int) e.CurrentFileProgress / 20) * 20;
             if (progress == _txProgress)
-- 
GitLab