From 2766611878e5b20ba419b050aa6f01741837112f Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Sun, 25 Sep 2022 20:56:45 -0400 Subject: [PATCH] Small Fixes --- CMakeLists.txt | 5 +++++ launcher/src/client/cache.cpp | 24 ++++++++++++------------ libreborn/src/util/util.c | 2 +- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cca244215..1f91633a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,10 @@ cmake_minimum_required(VERSION 3.16.0) +# Avoid Warning About DOWNLOAD_EXTRACT_TIMESTAMP +if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24.0) + cmake_policy(SET CMP0135 NEW) +endif() + # Build Mode set(MCPI_BUILD_MODE "native" CACHE STRING "\"arm\" = Build Only Code That Must Be ARM; \"native\" = Build Architecture-Independent Code") set_property(CACHE MCPI_BUILD_MODE PROPERTY STRINGS "arm" "native") diff --git a/launcher/src/client/cache.cpp b/launcher/src/client/cache.cpp index 70e6369c6..afb08230b 100644 --- a/launcher/src/client/cache.cpp +++ b/launcher/src/client/cache.cpp @@ -30,9 +30,6 @@ launcher_cache load_cache() { // Log DEBUG("Loading Launcher Cache..."); - // Lock File - int lock_fd = lock_file(get_cache_path().c_str()); - // Return Value launcher_cache ret = empty_cache; @@ -46,6 +43,9 @@ launcher_cache load_cache() { WARN("Unable To Open Launcher Cache For Loading"); } } else { + // Lock File + int lock_fd = lock_file(get_cache_path().c_str()); + // Check Version unsigned char cache_version; stream.read((char *) &cache_version, 1); @@ -84,10 +84,10 @@ launcher_cache load_cache() { ret = cache; } } - } - // Unlock File - unlock_file(get_cache_path().c_str(), lock_fd); + // Unlock File + unlock_file(get_cache_path().c_str(), lock_fd); + } // Return return ret; @@ -106,15 +106,15 @@ void save_cache() { // Log DEBUG("Saving Launcher Cache..."); - // Lock File - int lock_fd = lock_file(get_cache_path().c_str()); - // Open File std::ofstream stream(get_cache_path(), std::ios::out | std::ios::binary); if (!stream) { // Fail WARN("Unable To Open Launcher Cache For Saving"); } else { + // Lock File + int lock_fd = lock_file(get_cache_path().c_str()); + // Save Cache Version unsigned char cache_version = (unsigned char) CACHE_VERSION; stream.write((const char *) &cache_version, 1); @@ -153,10 +153,10 @@ void save_cache() { if (!stream.good()) { WARN("Failure While Saving Launcher Cache"); } - } - // Unlock File - unlock_file(get_cache_path().c_str(), lock_fd); + // Unlock File + unlock_file(get_cache_path().c_str(), lock_fd); + } } // Wipe Cache diff --git a/libreborn/src/util/util.c b/libreborn/src/util/util.c index 0aa32ad2c..5d5af3450 100644 --- a/libreborn/src/util/util.c +++ b/libreborn/src/util/util.c @@ -28,7 +28,7 @@ int is_progress_difference_significant(int32_t new_val, int32_t old_val) { // Lock File int lock_file(const char *file) { - int fd = open(file, O_WRONLY | O_CREAT, S_IWUSR); + int fd = open(file, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); if (fd == -1) { ERR("Unable To Open Lock File: %s: %s", file, strerror(errno)); }