From ca6e214aa5fa753f730ea896f8d9a4718a6dca9b Mon Sep 17 00:00:00 2001 From: Pyrix25633 Date: Thu, 23 Jun 2022 14:45:57 +0200 Subject: [PATCH] 1.4.0, sleep time is from start to start, not from end to start --- Program.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Program.cs b/Program.cs index a20ee38..03647e0 100644 --- a/Program.cs +++ b/Program.cs @@ -12,8 +12,9 @@ static void Main(string[] args) { enumOptions.RecurseSubdirectories = true; // Other variables Int32 length, filesToCopy, filesCopied, foldersToCopy, foldersCopied, - filesToRemove, filesRemoved, foldersToRemove, foldersRemoved; + filesToRemove, filesRemoved, foldersToRemove, foldersRemoved, sleepTime; UInt64 sizeToCopy, sizeCopied, sizeToRemove, sizeRemoved; + Int64 timestamp; // Parsing arguments Arguments arguments = new Arguments(); try { @@ -105,6 +106,8 @@ static void Main(string[] args) { Logger.Info("Extension list not set, only file size will be used to compare files"); } while(true) { + // Timestamp + timestamp = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds() + arguments.time; // Scan folders Logger.Info("Starting source folder scan..."); try { @@ -319,7 +322,9 @@ static void Main(string[] args) { // Close log stream Logger.TerminateLogging(); if(!arguments.repeat) break; - Thread.Sleep(arguments.time * 1000); + sleepTime = (Int32)(timestamp - new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds()); + Logger.Info("Waiting " + sleepTime + " seconds from now, process can be terminated with 'Ctrl + C' before the next scan"); + if(sleepTime > 0) Thread.Sleep(sleepTime * 1000); // Reopen log stream Logger.ReinitializeLogging(); }