Files
react-native-code-push/windows/FileUtils.cs
Eric Rozell b72bf77e25 fix(async): Changing all await calls to .ConfigureAwait(false)
The async calls in CodePush for ReactWindows can all be executed on any background thread, so adding .ConfigureAwait(false) can improve performance and reduce the likelihood of deadlock.  The blocking calls in `InitializeUpdateAfterRestart()` were hanging, but now that .ConfigureAwait(false) is used pervasively, it is no longer a problem.

Fixes #550
2016-10-05 09:47:20 -04:00

24 lines
1.0 KiB
C#

using System;
using System.Threading.Tasks;
using Windows.Storage;
namespace CodePush.ReactNative
{
internal class FileUtils
{
internal async static Task MergeFoldersAsync(StorageFolder source, StorageFolder target)
{
foreach (StorageFile sourceFile in await source.GetFilesAsync().AsTask().ConfigureAwait(false))
{
await sourceFile.CopyAndReplaceAsync(await target.CreateFileAsync(sourceFile.Name, CreationCollisionOption.OpenIfExists).AsTask().ConfigureAwait(false)).AsTask().ConfigureAwait(false);
}
foreach (StorageFolder sourceDirectory in await source.GetFoldersAsync().AsTask().ConfigureAwait(false))
{
StorageFolder nextTargetSubDir = await target.CreateFolderAsync(sourceDirectory.Name, CreationCollisionOption.OpenIfExists).AsTask().ConfigureAwait(false);
await MergeFoldersAsync(sourceDirectory, nextTargetSubDir).ConfigureAwait(false);
}
}
}
}