Fix deadlock during log rotations.

PiperOrigin-RevId: 622916139
This commit is contained in:
Francis Tsui
2024-04-08 12:10:26 -07:00
committed by Copybara-Service
parent 8f51d92f22
commit d69bd78d13
4 changed files with 13 additions and 3 deletions
+3 -1
View File
@@ -15,7 +15,8 @@
#ifndef PLATFORM_PUBLIC_DEVICE_INFO_H_
#define PLATFORM_PUBLIC_DEVICE_INFO_H_
#include <filesystem>
#include <cstddef>
#include <filesystem> // NOLINT
#include <functional>
#include <optional>
#include <string>
@@ -41,6 +42,7 @@ class DeviceInfo {
virtual std::filesystem::path GetDownloadPath() const = 0;
virtual std::filesystem::path GetAppDataPath() const = 0;
virtual std::filesystem::path GetTemporaryPath() const = 0;
virtual std::filesystem::path GetLogPath() const = 0;
virtual std::optional<size_t> GetAvailableDiskSpaceInBytes(
const std::filesystem::path& path) const = 0;
+5
View File
@@ -89,6 +89,11 @@ std::filesystem::path DeviceInfoImpl::GetTemporaryPath() const {
nearby::sharing::CurrentDirectory());
}
std::filesystem::path DeviceInfoImpl::GetLogPath() const {
std::optional<std::filesystem::path> path = device_info_impl_->GetLogPath();
return path.value_or(GetTemporaryPath());
}
std::optional<size_t> DeviceInfoImpl::GetAvailableDiskSpaceInBytes(
const std::filesystem::path& path) const {
std::error_code error_code;
+2 -1
View File
@@ -16,7 +16,7 @@
#define PLATFORM_PUBLIC_DEVICE_INFO_IMPL_H_
#include <cstddef>
#include <filesystem>
#include <filesystem> // NOLINT
#include <functional>
#include <memory>
#include <optional>
@@ -46,6 +46,7 @@ class DeviceInfoImpl : public DeviceInfo {
std::filesystem::path GetDownloadPath() const override;
std::filesystem::path GetAppDataPath() const override;
std::filesystem::path GetTemporaryPath() const override;
std::filesystem::path GetLogPath() const override;
std::optional<size_t> GetAvailableDiskSpaceInBytes(
const std::filesystem::path& path) const override;
+3 -1
View File
@@ -16,7 +16,7 @@
#define THIRD_PARTY_NEARBY_INTERNAL_TEST_FAKE_DEVICE_INFO_H_
#include <cstddef>
#include <filesystem>
#include <filesystem> // NOLINT
#include <functional>
#include <limits>
#include <optional>
@@ -63,6 +63,8 @@ class FakeDeviceInfo : public DeviceInfo {
std::filesystem::path GetTemporaryPath() const override { return temp_path_; }
std::filesystem::path GetLogPath() const override { return temp_path_; }
std::optional<size_t> GetAvailableDiskSpaceInBytes(
const std::filesystem::path& path) const override {
std::wstring path_key = path.wstring();