2019-12-26 14:45:42 -05:00
// Copyright Epic Games, Inc. All Rights Reserved.
2019-02-05 18:09:08 -05:00
# include "BackgroundHttpManagerImpl.h"
2020-09-01 14:07:48 -04:00
# include "CoreTypes.h"
2019-09-04 15:27:24 -04:00
# include "PlatformBackgroundHttp.h"
2019-02-05 18:09:08 -05:00
2019-03-25 19:44:02 -04:00
# include "HAL/FileManager.h"
2020-05-06 17:58:18 -04:00
# include "HAL/PlatformFileManager.h"
2019-02-07 06:02:33 -05:00
# include "HAL/PlatformAtomics.h"
# include "HAL/PlatformFile.h"
2019-03-25 19:44:02 -04:00
# include "Misc/ConfigCacheIni.h"
2020-09-01 14:07:48 -04:00
# include "Misc/Paths.h"
2019-02-07 06:02:33 -05:00
# include "Misc/ScopeRWLock.h"
2020-09-01 14:07:48 -04:00
# include "Stats/Stats.h"
2019-02-05 18:09:08 -05:00
DEFINE_LOG_CATEGORY ( LogBackgroundHttpManager ) ;
FBackgroundHttpManagerImpl : : FBackgroundHttpManagerImpl ( )
: PendingStartRequests ( )
, PendingRequestLock ( )
, ActiveRequests ( )
, ActiveRequestLock ( )
, NumCurrentlyActiveRequests ( 0 )
2019-08-21 09:37:24 -04:00
, MaxActiveDownloads ( 4 )
2020-09-01 14:07:48 -04:00
, FileHashHelper ( MakeShared < FBackgroundHttpFileHashHelper , ESPMode : : ThreadSafe > ( ) )
2019-02-05 18:09:08 -05:00
{
}
FBackgroundHttpManagerImpl : : ~ FBackgroundHttpManagerImpl ( )
{
}
void FBackgroundHttpManagerImpl : : Initialize ( )
{
2020-09-01 14:07:48 -04:00
//Make sure we have attempted to load data at initialize
GetFileHashHelper ( ) - > LoadData ( ) ;
DeleteStaleTempFiles ( ) ;
2019-08-21 09:37:24 -04:00
// Can't read into an atomic int directly
int MaxActiveDownloadsConfig = 4 ;
2020-09-01 14:07:48 -04:00
ensureAlwaysMsgf ( GConfig - > GetInt ( TEXT ( " BackgroundHttp " ) , TEXT ( " MaxActiveDownloads " ) , MaxActiveDownloadsConfig , GEngineIni ) , TEXT ( " No value found for MaxActiveDownloads! Defaulting to 4! " ) ) ;
2019-08-21 09:37:24 -04:00
MaxActiveDownloads = MaxActiveDownloadsConfig ;
2019-02-05 18:09:08 -05:00
}
void FBackgroundHttpManagerImpl : : Shutdown ( )
{
//Pending Requests Clear
{
FRWScopeLock ScopeLock ( PendingRequestLock , SLT_Write ) ;
PendingStartRequests . Empty ( ) ;
}
//Active Requests Clear
{
FRWScopeLock ScopeLock ( ActiveRequestLock , SLT_Write ) ;
ActiveRequests . Empty ( ) ;
NumCurrentlyActiveRequests = 0 ;
}
}
2020-09-01 14:07:48 -04:00
void FBackgroundHttpManagerImpl : : DeleteStaleTempFiles ( )
2019-03-25 19:44:02 -04:00
{
2020-09-01 14:07:48 -04:00
//Parse our .ini values to determine how much we clean in this fuction
2019-03-25 19:44:02 -04:00
double FileAgeTimeOutSettings = - 1 ;
2020-09-01 14:07:48 -04:00
bool bDeleteTimedOutFiles = ( FileAgeTimeOutSettings > = 0 ) ;
bool bDeleteTempFilesWithoutURLMappings = false ;
bool bRemoveURLMappingEntriesWithoutPhysicalTempFiles = false ;
2019-03-25 19:44:02 -04:00
{
2020-09-01 14:07:48 -04:00
GConfig - > GetDouble ( TEXT ( " BackgroundHttp " ) , TEXT ( " TempFileTimeOutSeconds " ) , FileAgeTimeOutSettings , GEngineIni ) ;
bDeleteTimedOutFiles = ( FileAgeTimeOutSettings > = 0 ) ;
GConfig - > GetBool ( TEXT ( " BackgroundHttp " ) , TEXT ( " DeleteTempFilesWithoutURLMappingEntries " ) , bDeleteTempFilesWithoutURLMappings , GEngineIni ) ;
GConfig - > GetBool ( TEXT ( " BackgroundHttp " ) , TEXT ( " RemoveURLMappingEntriesWithoutPhysicalTempFiles " ) , bRemoveURLMappingEntriesWithoutPhysicalTempFiles , GEngineIni ) ;
UE_LOG ( LogBackgroundHttpManager , Log , TEXT ( " Stale Settings -- TempFileTimeOutSeconds:%f DeleteTempFilesWithoutURLMappingEntries:%d RemoveURLMappingEntriesWithoutPhysicalTempFiles:%d " ) , static_cast < float > ( FileAgeTimeOutSettings ) , static_cast < int > ( bDeleteTempFilesWithoutURLMappings ) , static_cast < int > ( bRemoveURLMappingEntriesWithoutPhysicalTempFiles ) ) ;
}
const bool bWillDoAnyWork = bDeleteTimedOutFiles | | bDeleteTempFilesWithoutURLMappings | | bRemoveURLMappingEntriesWithoutPhysicalTempFiles ;
//Only bother gathering temp files if we will actually be doing something with them
TArray < FString > AllTempFilesToCheck ;
if ( bWillDoAnyWork )
{
GatherAllTempFilenames ( AllTempFilesToCheck ) ;
UE_LOG ( LogBackgroundHttpManager , Display , TEXT ( " Found %d temp download files. " ) , AllTempFilesToCheck . Num ( ) ) ;
}
//Handle all timed out files based on the .ini time out settings
//can be turned off by setting
if ( bDeleteTimedOutFiles )
{
TArray < FString > TimedOutFiles ;
GatherTempFilesOlderThen ( TimedOutFiles , FileAgeTimeOutSettings , & AllTempFilesToCheck ) ;
TArray < FString > TimeOutDeleteFullPaths ;
ConvertAllTempFilenamesToFullPaths ( TimeOutDeleteFullPaths , TimedOutFiles ) ;
for ( const FString & FullFilePath : TimeOutDeleteFullPaths )
{
if ( IFileManager : : Get ( ) . Delete ( * FullFilePath ) )
{
UE_LOG ( LogBackgroundHttpManager , Log , TEXT ( " Successfully deleted %s due to time out settings " ) , * FullFilePath ) ;
}
else
{
UE_LOG ( LogBackgroundHttpManager , Error , TEXT ( " Failed to delete timed out file %s " ) , * FullFilePath ) ;
}
}
//Should remove these files from the list of files we are checking as we know they are already invalid from timing out, so we shouldn't check them twice
for ( const FString & RemovedFile : TimedOutFiles )
{
AllTempFilesToCheck . Remove ( RemovedFile ) ;
}
}
//Handle all temp files that should be removed because they are missing a corresponding URL mapping
if ( bDeleteTempFilesWithoutURLMappings )
{
TArray < FString > MissingURLMappingFiles ;
GatherTempFilesWithoutURLMappings ( MissingURLMappingFiles , & AllTempFilesToCheck ) ;
TArray < FString > MissingURLDeleteFullPaths ;
ConvertAllTempFilenamesToFullPaths ( MissingURLDeleteFullPaths , MissingURLMappingFiles ) ;
for ( const FString & FullFilePath : MissingURLDeleteFullPaths )
{
if ( IFileManager : : Get ( ) . Delete ( * FullFilePath ) )
{
UE_LOG ( LogBackgroundHttpManager , Log , TEXT ( " Successfully deleted %s due to missing a URL mapping for this temp data " ) , * FullFilePath ) ;
}
else
{
UE_LOG ( LogBackgroundHttpManager , Error , TEXT ( " Failed to delete file %s that was being deleted due to a missing URL mapping " ) , * FullFilePath ) ;
}
}
//Should remove these files from the list of files we are checking as we know they are already invalid from timing out, so we shouldn't check them twice
for ( const FString & RemovedFile : MissingURLMappingFiles )
{
AllTempFilesToCheck . Remove ( RemovedFile ) ;
}
}
if ( bRemoveURLMappingEntriesWithoutPhysicalTempFiles )
{
//Remove all URL map entries that don't correspond to a physical file on disk
GetFileHashHelper ( ) - > DeleteURLMappingsWithoutTempFiles ( ) ;
}
UE_LOG ( LogBackgroundHttpManager , Log , TEXT ( " Kept %d temp download files: " ) , AllTempFilesToCheck . Num ( ) ) ;
for ( const FString & ValidFile : AllTempFilesToCheck )
{
UE_LOG ( LogBackgroundHttpManager , Verbose , TEXT ( " Kept: %s " ) , * ValidFile ) ;
}
}
void FBackgroundHttpManagerImpl : : GatherTempFilesOlderThen ( TArray < FString > & OutTimedOutTempFilenames , double SecondsToConsiderOld , TArray < FString > * OptionalFileList /* = nullptr */ ) const
{
OutTimedOutTempFilenames . Empty ( ) ;
TArray < FString > GatheredFullFilePathFiles ;
//OptionalFileList was not supplied so we need to gather all temp files to check as full file paths
if ( nullptr = = OptionalFileList )
{
GatherAllTempFilenames ( GatheredFullFilePathFiles , true ) ;
}
//We supplied an OptionalFileList, but we still need a full file path list for this operation
else
{
ConvertAllTempFilenamesToFullPaths ( GatheredFullFilePathFiles , * OptionalFileList ) ;
}
if ( SecondsToConsiderOld > = 0 )
{
UE_LOG ( LogBackgroundHttpManager , Verbose , TEXT ( " Checking for BackgroundHTTP temp files that are older then: %lf " ) , SecondsToConsiderOld ) ;
for ( const FString & FullFilePath : GatheredFullFilePathFiles )
2019-03-25 19:44:02 -04:00
{
2019-03-30 01:04:17 -04:00
FFileStatData FileData = IFileManager : : Get ( ) . GetStatData ( * FullFilePath ) ;
FTimespan TimeSinceCreate = FDateTime : : UtcNow ( ) - FileData . CreationTime ;
const double FileAge = TimeSinceCreate . GetTotalSeconds ( ) ;
2020-09-01 14:07:48 -04:00
const bool bShouldReturn = ( FileAge > SecondsToConsiderOld ) ;
if ( bShouldReturn )
2019-03-25 19:44:02 -04:00
{
2020-09-01 14:07:48 -04:00
UE_LOG ( LogBackgroundHttpManager , Verbose , TEXT ( " FoundTempFile: %s with age %lf " ) , * FullFilePath , FileAge ) ;
//Need to save output as just filename to be consistent with other functions
OutTimedOutTempFilenames . Add ( FPaths : : GetCleanFilename ( FullFilePath ) ) ;
2019-03-25 19:44:02 -04:00
}
}
}
}
2020-09-01 14:07:48 -04:00
void FBackgroundHttpManagerImpl : : GatherTempFilesWithoutURLMappings ( TArray < FString > & OutTempFilesMissingURLMappings , TArray < FString > * OptionalFileList /*= nullptr */ ) const
{
OutTempFilesMissingURLMappings . Empty ( ) ;
TArray < FString > * FileListToCheckPtr = OptionalFileList ;
//OptionalFileList was not supplied so we need to gather all temp files to check
TArray < FString > GatheredFiles ;
if ( nullptr = = FileListToCheckPtr )
{
GatherAllTempFilenames ( GatheredFiles , false ) ;
FileListToCheckPtr = & GatheredFiles ;
}
TArray < FString > & FilesToCheckRef = * FileListToCheckPtr ;
for ( const FString & File : FilesToCheckRef )
{
const FString * FoundURL = GetFileHashHelper ( ) - > FindMappedURLForTempFilename ( File ) ;
if ( nullptr = = FoundURL )
{
OutTempFilesMissingURLMappings . Add ( File ) ;
}
}
}
void FBackgroundHttpManagerImpl : : GatherAllTempFilenames ( TArray < FString > & OutAllTempFilenames , bool bOutputAsFullPaths /* = false */ ) const
{
OutAllTempFilenames . Empty ( ) ;
const FString DirectoryToCheck = GetFileHashHelper ( ) - > GetTemporaryRootPath ( ) ;
TArray < FString > AllFilenames ;
IFileManager : : Get ( ) . FindFiles ( AllFilenames , * DirectoryToCheck , * FBackgroundHttpFileHashHelper : : GetTempFileExtension ( ) ) ;
//Make into full paths for output
for ( const FString & Filename : AllFilenames )
{
if ( bOutputAsFullPaths )
{
OutAllTempFilenames . Add ( FPaths : : Combine ( DirectoryToCheck , Filename ) ) ;
}
else
{
OutAllTempFilenames . Add ( Filename ) ;
}
}
}
void FBackgroundHttpManagerImpl : : ConvertAllTempFilenamesToFullPaths ( TArray < FString > & OutFilenamesAsFullPaths , const TArray < FString > & FilenamesToConvertToFullPaths ) const
{
//Store this separetly so we don't get bad behavior if the same Array is supplied for both parameters
TArray < FString > FilenamesToOutput ;
for ( const FString & ExistingFilename : FilenamesToConvertToFullPaths )
{
FilenamesToOutput . Add ( FBackgroundHttpFileHashHelper : : GetFullPathOfTempFilename ( ExistingFilename ) ) ;
}
OutFilenamesAsFullPaths = FilenamesToOutput ;
}
void FBackgroundHttpManagerImpl : : DeleteAllTemporaryFiles ( )
2019-02-05 18:09:08 -05:00
{
UE_LOG ( LogBackgroundHttpManager , Log , TEXT ( " Cleaning Up Temporary Files " ) ) ;
TArray < FString > FilesToDelete ;
//Default implementation is to just delete everything in the Root Folder non-recursively.
IPlatformFile & PlatformFile = FPlatformFileManager : : Get ( ) . GetPlatformFile ( ) ;
2020-09-01 14:07:48 -04:00
PlatformFile . FindFiles ( FilesToDelete , * FBackgroundHttpFileHashHelper : : GetTemporaryRootPath ( ) , * FBackgroundHttpFileHashHelper : : GetTempFileExtension ( ) ) ;
2019-02-05 18:09:08 -05:00
for ( const FString & File : FilesToDelete )
{
UE_LOG ( LogBackgroundHttpManager , Log , TEXT ( " Deleting File:%s " ) , * File ) ;
const bool bDidDelete = PlatformFile . DeleteFile ( * File ) ;
if ( ! bDidDelete )
{
UE_LOG ( LogBackgroundHttpManager , Warning , TEXT ( " Failure to Delete Temp File:%s " ) , * File ) ;
}
}
}
2019-08-21 09:37:24 -04:00
int FBackgroundHttpManagerImpl : : GetMaxActiveDownloads ( ) const
{
return MaxActiveDownloads ;
}
void FBackgroundHttpManagerImpl : : SetMaxActiveDownloads ( int InMaxActiveDownloads )
{
MaxActiveDownloads = InMaxActiveDownloads ;
}
2019-02-05 18:09:08 -05:00
void FBackgroundHttpManagerImpl : : AddRequest ( const FBackgroundHttpRequestPtr Request )
{
UE_LOG ( LogBackgroundHttpManager , Log , TEXT ( " AddRequest Called - RequestID:%s " ) , * Request - > GetRequestID ( ) ) ;
//If we don't associate with any existing requests, go into our pending list. These will be moved into the ActiveRequest list during our Tick
if ( ! AssociateWithAnyExistingRequest ( Request ) )
{
FRWScopeLock ScopeLock ( PendingRequestLock , SLT_Write ) ;
PendingStartRequests . Add ( Request ) ;
UE_LOG ( LogBackgroundHttpManager , Log , TEXT ( " Adding BackgroundHttpRequest to PendingStartRequests - RequestID:%s " ) , * Request - > GetRequestID ( ) ) ;
}
}
void FBackgroundHttpManagerImpl : : RemoveRequest ( const FBackgroundHttpRequestPtr Request )
{
int NumRequestsRemoved = 0 ;
//Check if this request was in active list first
{
FRWScopeLock ScopeLock ( ActiveRequestLock , SLT_Write ) ;
2019-04-16 21:08:14 -04:00
NumRequestsRemoved = ActiveRequests . Remove ( Request ) ;
2019-02-05 18:09:08 -05:00
//If we removed an active request, lets decrement the NumCurrentlyActiveRequests accordingly
if ( NumRequestsRemoved ! = 0 )
{
NumCurrentlyActiveRequests = NumCurrentlyActiveRequests - NumRequestsRemoved ;
}
}
//Only search the PendingRequestList if we didn't remove it in our ActiveRequest List
if ( NumRequestsRemoved = = 0 )
{
FRWScopeLock ScopeLock ( PendingRequestLock , SLT_Write ) ;
2019-04-16 21:08:14 -04:00
NumRequestsRemoved = PendingStartRequests . Remove ( Request ) ;
2019-02-05 18:09:08 -05:00
}
2020-09-01 14:07:48 -04:00
2019-02-05 18:09:08 -05:00
UE_LOG ( LogBackgroundHttpManager , Log , TEXT ( " FGenericPlatformBackgroundHttpManager::RemoveRequest Called - RequestID:%s | NumRequestsActuallyRemoved:%d | NumCurrentlyActiveRequests:%d " ) , * Request - > GetRequestID ( ) , NumRequestsRemoved , NumCurrentlyActiveRequests ) ;
}
2020-09-01 14:07:48 -04:00
void FBackgroundHttpManagerImpl : : CleanUpDataAfterCompletingRequest ( const FBackgroundHttpRequestPtr Request )
{
//Need to free up all these URL's hashes in FileHashHelper so that future URLs can use those temp files
BackgroundHttpFileHashHelperRef OurFileHashHelper = GetFileHashHelper ( ) ;
const TArray < FString > & URLList = Request - > GetURLList ( ) ;
for ( const FString & URL : URLList )
{
OurFileHashHelper - > RemoveURLMapping ( URL ) ;
}
}
2019-02-05 18:09:08 -05:00
bool FBackgroundHttpManagerImpl : : AssociateWithAnyExistingRequest ( const FBackgroundHttpRequestPtr Request )
{
bool bDidAssociateWithExistingRequest = false ;
FString ExistingFilePath ;
int64 ExistingFileSize ;
if ( CheckForExistingCompletedDownload ( Request , ExistingFilePath , ExistingFileSize ) )
{
FBackgroundHttpResponsePtr NewResponseWithExistingFile = FPlatformBackgroundHttp : : ConstructBackgroundResponse ( EHttpResponseCodes : : Ok , ExistingFilePath ) ;
if ( ensureAlwaysMsgf ( NewResponseWithExistingFile . IsValid ( ) , TEXT ( " Failure to create FBackgroundHttpResponsePtr in FPlatformBackgroundHttp::ConstructBackgroundResponse! Can not associate new download with found finished download! " ) ) )
{
bDidAssociateWithExistingRequest = true ;
UE_LOG ( LogBackgroundHttpManager , Log , TEXT ( " Found existing background task to associate with! RequestID:%s | ExistingFileSize:%lld | ExistingFilePath:%s " ) , * Request - > GetRequestID ( ) , ExistingFileSize , * ExistingFilePath ) ;
//First send progress update for the file size so anything monitoring this download knows we are about to update this progress
Request - > OnProgressUpdated ( ) . ExecuteIfBound ( Request , ExistingFileSize , ExistingFileSize ) ;
//Now complete with this completed response data
Request - > CompleteWithExistingResponseData ( NewResponseWithExistingFile ) ;
}
}
return bDidAssociateWithExistingRequest ;
}
bool FBackgroundHttpManagerImpl : : CheckForExistingCompletedDownload ( const FBackgroundHttpRequestPtr Request , FString & ExistingFilePathOut , int64 & ExistingFileSizeOut )
{
bool bDidFindExistingDownload = false ;
IPlatformFile & PlatformFile = FPlatformFileManager : : Get ( ) . GetPlatformFile ( ) ;
const TArray < FString > & URLList = Request - > GetURLList ( ) ;
for ( const FString & URL : URLList )
{
2020-09-01 14:07:48 -04:00
const FString * FoundTempFilename = GetFileHashHelper ( ) - > FindTempFilenameMappingForURL ( URL ) ;
if ( nullptr ! = FoundTempFilename )
2019-02-05 18:09:08 -05:00
{
2020-09-01 14:07:48 -04:00
const FString & FileDestination = FBackgroundHttpFileHashHelper : : GetFullPathOfTempFilename ( * FoundTempFilename ) ;
if ( PlatformFile . FileExists ( * FileDestination ) )
{
bDidFindExistingDownload = true ;
ExistingFilePathOut = FileDestination ;
2019-02-05 18:09:08 -05:00
2020-09-01 14:07:48 -04:00
ExistingFileSizeOut = PlatformFile . FileSize ( * FileDestination ) ;
break ;
}
2019-02-05 18:09:08 -05:00
}
}
return bDidFindExistingDownload ;
}
bool FBackgroundHttpManagerImpl : : Tick ( float DeltaTime )
{
2020-09-01 14:07:48 -04:00
QUICK_SCOPE_CYCLE_COUNTER ( STAT_FBackgroundHttpManagerImpl_Tick ) ;
2019-02-05 18:09:08 -05:00
2020-09-01 14:07:48 -04:00
ensureAlwaysMsgf ( IsInGameThread ( ) , TEXT ( " Called from un-expected thread! Potential error in an implementation of background downloads! " ) ) ;
ActivatePendingRequests ( ) ;
//for now we are saving data every tick, could change this to be on an interval later if required
GetFileHashHelper ( ) - > SaveData ( ) ;
2019-02-05 18:09:08 -05:00
//Keep ticking in all cases, so just return true
return true ;
}
void FBackgroundHttpManagerImpl : : ActivatePendingRequests ( )
{
2019-11-27 14:52:23 -05:00
FBackgroundHttpRequestPtr HighestPriorityRequestToStart = nullptr ;
EBackgroundHTTPPriority HighestRequestPriority = EBackgroundHTTPPriority : : Num ;
2019-02-05 18:09:08 -05:00
2019-11-27 14:52:23 -05:00
//Go through and find the highest priority request
2019-02-05 18:09:08 -05:00
{
2019-11-27 18:04:49 -05:00
FRWScopeLock ActiveScopeLock ( ActiveRequestLock , SLT_ReadOnly ) ;
FRWScopeLock PendingScopeLock ( PendingRequestLock , SLT_ReadOnly ) ;
const int NumRequestsWeCanProcess = ( MaxActiveDownloads - NumCurrentlyActiveRequests ) ;
if ( NumRequestsWeCanProcess > 0 )
2019-02-05 18:09:08 -05:00
{
2019-11-27 18:04:49 -05:00
if ( PendingStartRequests . Num ( ) > 0 )
2019-02-05 18:09:08 -05:00
{
2019-11-27 18:04:49 -05:00
UE_LOG ( LogBackgroundHttpManager , Verbose , TEXT ( " Populating Requests to Start from PendingStartRequests - MaxActiveDownloads:%d | NumCurrentlyActiveRequests:%d | NumPendingStartRequests:%d " ) , MaxActiveDownloads . Load ( ) , NumCurrentlyActiveRequests , PendingStartRequests . Num ( ) ) ;
2019-04-16 21:08:14 -04:00
2019-11-27 18:04:49 -05:00
HighestPriorityRequestToStart = PendingStartRequests [ 0 ] ;
HighestRequestPriority = HighestPriorityRequestToStart . IsValid ( ) ? HighestPriorityRequestToStart - > GetRequestPriority ( ) : EBackgroundHTTPPriority : : Num ;
//See how many more requests we can process and only do anything if we can still process more
{
for ( int RequestIndex = 1 ; RequestIndex < PendingStartRequests . Num ( ) ; + + RequestIndex )
2019-11-27 14:52:23 -05:00
{
2019-11-27 18:04:49 -05:00
FBackgroundHttpRequestPtr PendingRequestToCheck = PendingStartRequests [ RequestIndex ] ;
EBackgroundHTTPPriority PendingRequestPriority = PendingRequestToCheck . IsValid ( ) ? PendingRequestToCheck - > GetRequestPriority ( ) : EBackgroundHTTPPriority : : Num ;
//Found a higher priority request, so track that one
if ( PendingRequestPriority < HighestRequestPriority )
{
HighestPriorityRequestToStart = PendingRequestToCheck ;
HighestRequestPriority = PendingRequestPriority ;
}
2019-11-27 14:52:23 -05:00
}
}
2019-02-05 18:09:08 -05:00
}
}
}
2019-11-27 14:52:23 -05:00
if ( HighestPriorityRequestToStart . IsValid ( ) )
2019-02-05 18:09:08 -05:00
{
2019-11-27 14:52:23 -05:00
UE_LOG ( LogBackgroundHttpManager , Verbose , TEXT ( " Starting Request: %s Priority:%s " ) , * HighestPriorityRequestToStart - > GetRequestID ( ) , LexToString ( HighestRequestPriority ) ) ;
2019-02-05 18:09:08 -05:00
//Actually move request to Active list now
2019-11-27 18:04:49 -05:00
FRWScopeLock ActiveScopeLock ( ActiveRequestLock , SLT_Write ) ;
FRWScopeLock PendingScopeLock ( PendingRequestLock , SLT_Write ) ;
2019-11-27 14:52:23 -05:00
ActiveRequests . Add ( HighestPriorityRequestToStart ) ;
PendingStartRequests . RemoveSingle ( HighestPriorityRequestToStart ) ;
2019-02-05 18:09:08 -05:00
2019-04-16 21:08:14 -04:00
+ + NumCurrentlyActiveRequests ;
2019-02-05 18:09:08 -05:00
//Call Handle for that task to now kick itself off
2019-11-27 14:52:23 -05:00
HighestPriorityRequestToStart - > HandleDelayedProcess ( ) ;
2019-02-05 18:09:08 -05:00
}
}
2020-09-01 14:07:48 -04:00
FString FBackgroundHttpManagerImpl : : GetTempFileLocationForURL ( const FString & URL )
{
const FString & TempLocation = GetFileHashHelper ( ) - > FindOrAddTempFilenameMappingForURL ( URL ) ;
return FBackgroundHttpFileHashHelper : : GetFullPathOfTempFilename ( TempLocation ) ;
}