Commit 93dbe9e9 authored by Nicolas Jager's avatar Nicolas Jager

internal : add creation token to protect against crash

Change-Id: Ice9291bd774de6f8ec21058a3d99885f24c0cc6f
Tuleap: #1227
parent df0a067a
......@@ -52,11 +52,42 @@ LoadingPage::LoadingPage()
.then([this](bool config_exists)
{
if (config_exists) {
this->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, ref new Windows::UI::Core::DispatchedHandler([this] () {
this->Frame->Navigate(Windows::UI::Xaml::Interop::TypeName(MainPage::typeid));
}));
Utils::fileExists(ApplicationData::Current->LocalFolder, "creation.token")
.then([this](bool token_exists)
{
if (token_exists) {
/* we have a token, the config has to be considered as corrupted, summon the wizard */
Utils::fileExists(ApplicationData::Current->LocalFolder, ".config\\dring.yml")
.then([this](bool token_exists)
{
if (token_exists) {
StorageFolder^ storageFolder = ApplicationData::Current->LocalFolder;
task<StorageFile^>(storageFolder->GetFileAsync(".config\\dring.yml")).then([this](StorageFile^ folder)
{
folder->DeleteAsync();
});
}
});
this->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, ref new Windows::UI::Core::DispatchedHandler([this]() {
this->Frame->Navigate(Windows::UI::Xaml::Interop::TypeName(Wizard::typeid));
}));
}
else {
/* there is no token and we have a config.yml, summon the main page */
this->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, ref new Windows::UI::Core::DispatchedHandler([this]() {
this->Frame->Navigate(Windows::UI::Xaml::Interop::TypeName(MainPage::typeid));
}));
}
});
}
else {
/* no config file, create the token and summon the wizard*/
StorageFolder^ storageFolder = ApplicationData::Current->LocalFolder;
storageFolder->CreateFileAsync("creation.token", CreationCollisionOption::ReplaceExisting);
this->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, ref new Windows::UI::Core::DispatchedHandler([this] () {
this->Frame->Navigate(Windows::UI::Xaml::Interop::TypeName(Wizard::typeid));
}));
......
......@@ -528,6 +528,21 @@ RingClientUWP::RingD::startDaemon()
}
}
/* at this point the config.yml is safe. */
Utils::fileExists(ApplicationData::Current->LocalFolder, "creation.token")
.then([this](bool token_exists)
{
if (token_exists) {
StorageFolder^ storageFolder = ApplicationData::Current->LocalFolder;
task<StorageFile^>(storageFolder->GetFileAsync("creation.token")).then([this](StorageFile^ file)
{
file->DeleteAsync();
});
}
});
while (true) {
DRing::pollEvents();
dequeueTasks();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment