From 582c936e3b5eb027cffa467532ed73a5ac20d681 Mon Sep 17 00:00:00 2001 From: amzn-mike <80125227+amzn-mike@users.noreply.github.com> Date: Sat, 19 Jun 2021 18:37:48 -0500 Subject: [PATCH 1/2] Move begin/end cache file update calls into move/copy code --- .../native/resourcecompiler/rcjob.cpp | 14 -------------- .../AssetProcessor/native/utilities/assetUtils.cpp | 13 ++++++++++++- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/Code/Tools/AssetProcessor/native/resourcecompiler/rcjob.cpp b/Code/Tools/AssetProcessor/native/resourcecompiler/rcjob.cpp index 3d0b29a916..5c2ef9e6c6 100644 --- a/Code/Tools/AssetProcessor/native/resourcecompiler/rcjob.cpp +++ b/Code/Tools/AssetProcessor/native/resourcecompiler/rcjob.cpp @@ -788,13 +788,6 @@ namespace AssetProcessor // if we get here, we are good to go in terms of disk space and sources existing, so we make the best attempt we can. // first, we broadcast the name of ALL of the outputs we are about to change: - for (const QPair& filePair : outputsToCopy) - { - const QString& productAbsolutePath = filePair.second; - // note that this absolute path is a real file system path, and the following API requires normalized paths: - QString normalized = AssetUtilities::NormalizeFilePath(productAbsolutePath); - AssetProcessor::ProcessingJobInfoBus::Broadcast(&AssetProcessor::ProcessingJobInfoBus::Events::BeginCacheFileUpdate, normalized.toUtf8().constData()); - } // after we do the above notify its important that we do not early exit this function without undoing those locks. @@ -823,13 +816,6 @@ namespace AssetProcessor // once we're done, regardless of success or failure, we 'unlock' those files for further process. // if we failed, also re-trigger them to rebuild (the bool param at the end of the ebus call) - for (const QPair& filePair : outputsToCopy) - { - const QString& productAbsolutePath = filePair.second; - // note that this absolute path is a real file system path, and the following API requires normalized paths: - QString normalized = AssetUtilities::NormalizeFilePath(productAbsolutePath); - AssetProcessor::ProcessingJobInfoBus::Broadcast(&AssetProcessor::ProcessingJobInfoBus::Events::EndCacheFileUpdate, normalized.toUtf8().constData(), anyFileFailed); - } return !anyFileFailed; } diff --git a/Code/Tools/AssetProcessor/native/utilities/assetUtils.cpp b/Code/Tools/AssetProcessor/native/utilities/assetUtils.cpp index 19423358b5..60b1a893ed 100644 --- a/Code/Tools/AssetProcessor/native/utilities/assetUtils.cpp +++ b/Code/Tools/AssetProcessor/native/utilities/assetUtils.cpp @@ -88,6 +88,10 @@ namespace AssetUtilsInternal timer.start(); do { + QString normalized = AssetUtilities::NormalizeFilePath(outputFile); + AssetProcessor::ProcessingJobInfoBus::Broadcast( + &AssetProcessor::ProcessingJobInfoBus::Events::BeginCacheFileUpdate, normalized.toUtf8().constData()); + //Removing the old file if it exists if (outFile.exists()) { @@ -139,10 +143,17 @@ namespace AssetUtilsInternal } } while (!timer.hasExpired(waitTimeInSeconds * 1000)); //We will keep retrying until the timer has expired the inputted timeout + // note that this absolute path is a real file system path, and the following API requires normalized paths: + QString normalized = AssetUtilities::NormalizeFilePath(outputFile); + AssetProcessor::ProcessingJobInfoBus::Broadcast( + &AssetProcessor::ProcessingJobInfoBus::Events::EndCacheFileUpdate, normalized.toUtf8().constData(), !operationSucceeded); + if (!operationSucceeded) { //operation failed for the given timeout - AZ_Warning(AssetProcessor::ConsoleChannel, false, "WARNING: Could not copy/move source %s to %s, giving up\n", sourceFile.toUtf8().constData(), outputFile.toUtf8().constData()); + AZ_Warning(AssetProcessor::ConsoleChannel, false, "WARNING: Could not %s source from %s to %s, giving up\n", + isCopy ? "copy" : "move (via rename)", + sourceFile.toUtf8().constData(), outputFile.toUtf8().constData()); return false; } else if (failureOccurredOnce) From 4c7a46850d315e42822a3a10ade39a491ab0e596 Mon Sep 17 00:00:00 2001 From: amzn-mike <80125227+amzn-mike@users.noreply.github.com> Date: Mon, 21 Jun 2021 11:23:24 -0500 Subject: [PATCH 2/2] Update comments --- Code/Tools/AssetProcessor/native/resourcecompiler/rcjob.cpp | 6 ------ Code/Tools/AssetProcessor/native/utilities/assetUtils.cpp | 5 +++-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/Code/Tools/AssetProcessor/native/resourcecompiler/rcjob.cpp b/Code/Tools/AssetProcessor/native/resourcecompiler/rcjob.cpp index 5c2ef9e6c6..99880fc933 100644 --- a/Code/Tools/AssetProcessor/native/resourcecompiler/rcjob.cpp +++ b/Code/Tools/AssetProcessor/native/resourcecompiler/rcjob.cpp @@ -787,9 +787,6 @@ namespace AssetProcessor } // if we get here, we are good to go in terms of disk space and sources existing, so we make the best attempt we can. - // first, we broadcast the name of ALL of the outputs we are about to change: - - // after we do the above notify its important that we do not early exit this function without undoing those locks. bool anyFileFailed = false; @@ -813,9 +810,6 @@ namespace AssetProcessor AZ_TracePrintf(AssetBuilderSDK::WarningWindow, "Unable to change permission for the file: %s.\n", productAbsolutePath.toUtf8().data()); } } - - // once we're done, regardless of success or failure, we 'unlock' those files for further process. - // if we failed, also re-trigger them to rebuild (the bool param at the end of the ebus call) return !anyFileFailed; } diff --git a/Code/Tools/AssetProcessor/native/utilities/assetUtils.cpp b/Code/Tools/AssetProcessor/native/utilities/assetUtils.cpp index 60b1a893ed..81e7e7ab65 100644 --- a/Code/Tools/AssetProcessor/native/utilities/assetUtils.cpp +++ b/Code/Tools/AssetProcessor/native/utilities/assetUtils.cpp @@ -142,8 +142,9 @@ namespace AssetUtilsInternal } } } while (!timer.hasExpired(waitTimeInSeconds * 1000)); //We will keep retrying until the timer has expired the inputted timeout - - // note that this absolute path is a real file system path, and the following API requires normalized paths: + + // once we're done, regardless of success or failure, we 'unlock' those files for further process. + // if we failed, also re-trigger them to rebuild (the bool param at the end of the ebus call) QString normalized = AssetUtilities::NormalizeFilePath(outputFile); AssetProcessor::ProcessingJobInfoBus::Broadcast( &AssetProcessor::ProcessingJobInfoBus::Events::EndCacheFileUpdate, normalized.toUtf8().constData(), !operationSucceeded);