M module-services/service-desktop/ServiceDesktop.cpp => module-services/service-desktop/ServiceDesktop.cpp +1 -13
@@ 90,22 90,10 @@ sys::MessagePointer ServiceDesktop::DataReceivedHandler(sys::DataMessage * /*msg
return response;
}
-std::string ServiceDesktop::prepareSyncFilename()
-{
- const std::size_t maxFileNameSize = 64;
- std::array<char, maxFileNameSize> syncFileName{};
- std::time_t now;
- std::time(&now);
- std::strftime(syncFileName.data(), syncFileName.size(), "%FT%OH%OM%OSZ", std::localtime(&now));
-
- return std::string(syncFileName.data());
-}
-
void ServiceDesktop::prepareSyncData()
{
- syncStatus.taskId = prepareSyncFilename();
syncStatus.state = Sync::OperationState::Stopped;
- syncStatus.tempDir = purefs::dir::getTemporaryPath() / syncStatus.taskId;
+ syncStatus.tempDir = purefs::dir::getTemporaryPath() / "sync";
}
auto ServiceDesktop::requestLogsFlush() -> void
M module-services/service-desktop/Sync.cpp => module-services/service-desktop/Sync.cpp +2 -3
@@ 8,6 8,7 @@
#include <fstream>
#include <gsl/util>
#include <microtar.hpp>
+#include <service-desktop/Constants.hpp>
namespace sys
{
@@ 92,7 93,7 @@ bool Sync::PackSyncFiles(const std::filesystem::path &path)
}
auto isTarFileOpen = false;
- std::filesystem::path tarFilePath = (purefs::dir::getTemporaryPath() / path.filename());
+ std::filesystem::path tarFilePath = (purefs::dir::getTemporaryPath() / sdesktop::paths::syncFilename);
mtar_t tarFile;
auto cleanup = gsl::finally([&isTarFileOpen, &tarFile]() {
@@ 151,10 152,8 @@ bool Sync::PackSyncFiles(const std::filesystem::path &path)
readSize = purefs::buffer::tar_buf;
}
- LOG_DEBUG("Reading file ...");
fileStream.read(fileStreamBuffer.get(), readSize);
- LOG_DEBUG("Writing into sync package...");
if (mtar_write_data(&tarFile, fileStreamBuffer.get(), readSize) != MTAR_ESUCCESS) {
LOG_ERROR("Writing into sync package failed, quitting...");
return false;
M module-services/service-desktop/endpoints/backup/BackupHelper.cpp => module-services/service-desktop/endpoints/backup/BackupHelper.cpp +6 -25
@@ 64,36 64,17 @@ namespace sdesktop::endpoints
// return new generated sync package info
- return {sent::no,
- ResponseContext{.status = http::Code::Accepted,
- .body = json11::Json::object{
- {sdesktop::endpoints::json::taskId, ownerServicePtr->getSyncStatus().taskId}}}};
+ return {sent::no, ResponseContext{.status = http::Code::Accepted, .body = json11::Json::object{}}};
}
}
- auto BackupHelper::checkSyncState(Context &context) -> ProcessResult
+ auto BackupHelper::checkSyncState([[maybe_unused]] Context &context) -> ProcessResult
{
- auto ownerServicePtr = static_cast<ServiceDesktop *>(owner);
- auto status = http::Code::BadRequest;
-
- if (!context.getBody()[json::taskId].is_string()) {
- LOG_DEBUG("Backup task not found");
- return {sent::no, ResponseContext{.status = status}};
- }
-
- if (ownerServicePtr->getSyncStatus().taskId != context.getBody()[json::taskId].string_value()) {
- status = http::Code::NotFound;
- return {sent::no, ResponseContext{.status = status}};
- }
+ const auto ownerServicePtr = static_cast<ServiceDesktop *>(owner);
+ const auto syncStatus = ownerServicePtr->getSyncStatus();
- auto syncStatus = ownerServicePtr->getSyncStatus();
-
- if (syncStatus.state == Sync::OperationState::Finished) {
- status = http::Code::SeeOther;
- }
- else {
- status = http::Code::OK;
- }
+ const auto status =
+ (syncStatus.state == Sync::OperationState::Finished) ? http::Code::SeeOther : http::Code::NoContent;
return {sent::no, ResponseContext{.status = status, .body = syncStatus}};
}
M module-services/service-desktop/endpoints/include/endpoints/deviceInfo/DeviceInfoEndpointCommon.hpp => module-services/service-desktop/endpoints/include/endpoints/deviceInfo/DeviceInfoEndpointCommon.hpp +0 -6
@@ 40,12 40,6 @@ namespace sdesktop::endpoints
{
return http::Code::BadRequest;
};
-
- protected:
- static constexpr auto updateFilename = "update.tar";
- static constexpr auto syncFilename = "sync.tar";
- static constexpr auto backupFilename = "backup.tar";
- static constexpr auto recoveryStatusFilename = "recovery_status.json";
};
} // namespace sdesktop::endpoints
M module-services/service-desktop/include/service-desktop/Constants.hpp => module-services/service-desktop/include/service-desktop/Constants.hpp +10 -1
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#pragma once
@@ 9,3 9,12 @@ namespace service::name
{
inline constexpr auto service_desktop = "ServiceDesktop";
}
+namespace sdesktop::paths
+{
+
+ inline constexpr auto updateFilename = "update.tar";
+ inline constexpr auto syncFilename = "sync.tar";
+ inline constexpr auto backupFilename = "backup.tar";
+ inline constexpr auto recoveryStatusFilename = "recovery_status.json";
+
+} // namespace sdesktop::paths
M module-services/service-desktop/include/service-desktop/Sync.hpp => module-services/service-desktop/include/service-desktop/Sync.hpp +0 -1
@@ 68,7 68,6 @@ class Sync
{
std::filesystem::path tempDir;
CompletionCode completionCode = CompletionCode::Success;
- std::string taskId;
OperationState state = OperationState::Stopped;
json11::Json to_json() const
{
M module-vfs/paths/filesystem_paths.cpp => module-vfs/paths/filesystem_paths.cpp +1 -1
@@ 65,7 65,7 @@ namespace purefs
std::filesystem::path getTemporaryPath() noexcept
{
- return getSystemDiskPath() / PATH_TMP;
+ return getUserDiskPath() / PATH_TMP;
}
std::filesystem::path getBootJSONPath() noexcept
M products/BellHybrid/services/desktop/endpoints/deviceInfo/DeviceInfoEndpoint.cpp => products/BellHybrid/services/desktop/endpoints/deviceInfo/DeviceInfoEndpoint.cpp +5 -4
@@ 42,10 42,11 @@ namespace sdesktop::endpoints
{json::currentRTCTime, std::to_string(static_cast<uint32_t>(std::time(nullptr)))},
{json::version, std::string(VERSION)},
{json::serialNumber, getSerialNumber()},
- {json::recoveryStatusFilePath, (purefs::dir::getTemporaryPath() / recoveryStatusFilename).string()},
- {json::updateFilePath, (purefs::dir::getTemporaryPath() / updateFilename).string()},
- {json::backupFilePath, (purefs::dir::getTemporaryPath() / backupFilename).string()},
- {json::syncFilePath, (purefs::dir::getTemporaryPath() / syncFilename).string()}}));
+ {json::recoveryStatusFilePath,
+ (purefs::dir::getTemporaryPath() / sdesktop::paths::recoveryStatusFilename).string()},
+ {json::updateFilePath, (purefs::dir::getTemporaryPath() / sdesktop::paths::updateFilename).string()},
+ {json::backupFilePath, (purefs::dir::getTemporaryPath() / sdesktop::paths::backupFilename).string()},
+ {json::syncFilePath, (purefs::dir::getTemporaryPath() / sdesktop::paths::syncFilename).string()}}));
return http::Code::OK;
}
M products/PurePhone/services/desktop/endpoints/deviceInfo/DeviceInfoEndpoint.cpp => products/PurePhone/services/desktop/endpoints/deviceInfo/DeviceInfoEndpoint.cpp +5 -4
@@ 57,10 57,11 @@ namespace sdesktop::endpoints
{json::version, std::string(VERSION)},
{json::serialNumber, getSerialNumber()},
{json::caseColour, getCaseColour()},
- {json::recoveryStatusFilePath, (purefs::dir::getTemporaryPath() / recoveryStatusFilename).string()},
- {json::updateFilePath, (purefs::dir::getTemporaryPath() / updateFilename).string()},
- {json::backupFilePath, (purefs::dir::getTemporaryPath() / backupFilename).string()},
- {json::syncFilePath, (purefs::dir::getTemporaryPath() / syncFilename).string()},
+ {json::recoveryStatusFilePath,
+ (purefs::dir::getTemporaryPath() / sdesktop::paths::recoveryStatusFilename).string()},
+ {json::updateFilePath, (purefs::dir::getTemporaryPath() / sdesktop::paths::updateFilename).string()},
+ {json::backupFilePath, (purefs::dir::getTemporaryPath() / sdesktop::paths::backupFilename).string()},
+ {json::syncFilePath, (purefs::dir::getTemporaryPath() / sdesktop::paths::syncFilename).string()},
{json::deviceToken, getDeviceToken()}}));
return http::Code::OK;
M scripts/lua/entry.lua => scripts/lua/entry.lua +3 -2
@@ 22,6 22,8 @@ local function display_image(path)
local raw_data = helpers.read_whole_file(path)
rec.gui.clear()
rec.gui.display_raw_img(600, 480, raw_data)
+ -- Give some time to an user to view the displayed image
+ rec.sys.sleep(5)
end
local function print_recovery_info()
@@ 56,13 58,12 @@ local function handle_script_success(boot_reason)
end
local function handle_script_failure(boot_reason, message)
- print(message)
display_image(scripts[boot_reason].img_failure)
+ print(message)
end
local function handle_exit(boot_reason_str, status, message)
generate_report_file(boot_reason_str, status, message)
- rec.sys.sleep(1)
rec.gui.clear()
end