mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Fix deadlock during log rotations.
PiperOrigin-RevId: 622916139
This commit is contained in:
committed by
Copybara-Service
parent
8f51d92f22
commit
d69bd78d13
@@ -15,7 +15,8 @@
|
|||||||
#ifndef PLATFORM_PUBLIC_DEVICE_INFO_H_
|
#ifndef PLATFORM_PUBLIC_DEVICE_INFO_H_
|
||||||
#define PLATFORM_PUBLIC_DEVICE_INFO_H_
|
#define PLATFORM_PUBLIC_DEVICE_INFO_H_
|
||||||
|
|
||||||
#include <filesystem>
|
#include <cstddef>
|
||||||
|
#include <filesystem> // NOLINT
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -41,6 +42,7 @@ class DeviceInfo {
|
|||||||
virtual std::filesystem::path GetDownloadPath() const = 0;
|
virtual std::filesystem::path GetDownloadPath() const = 0;
|
||||||
virtual std::filesystem::path GetAppDataPath() const = 0;
|
virtual std::filesystem::path GetAppDataPath() const = 0;
|
||||||
virtual std::filesystem::path GetTemporaryPath() const = 0;
|
virtual std::filesystem::path GetTemporaryPath() const = 0;
|
||||||
|
virtual std::filesystem::path GetLogPath() const = 0;
|
||||||
|
|
||||||
virtual std::optional<size_t> GetAvailableDiskSpaceInBytes(
|
virtual std::optional<size_t> GetAvailableDiskSpaceInBytes(
|
||||||
const std::filesystem::path& path) const = 0;
|
const std::filesystem::path& path) const = 0;
|
||||||
|
|||||||
@@ -89,6 +89,11 @@ std::filesystem::path DeviceInfoImpl::GetTemporaryPath() const {
|
|||||||
nearby::sharing::CurrentDirectory());
|
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(
|
std::optional<size_t> DeviceInfoImpl::GetAvailableDiskSpaceInBytes(
|
||||||
const std::filesystem::path& path) const {
|
const std::filesystem::path& path) const {
|
||||||
std::error_code error_code;
|
std::error_code error_code;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
#define PLATFORM_PUBLIC_DEVICE_INFO_IMPL_H_
|
#define PLATFORM_PUBLIC_DEVICE_INFO_IMPL_H_
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <filesystem>
|
#include <filesystem> // NOLINT
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
@@ -46,6 +46,7 @@ class DeviceInfoImpl : public DeviceInfo {
|
|||||||
std::filesystem::path GetDownloadPath() const override;
|
std::filesystem::path GetDownloadPath() const override;
|
||||||
std::filesystem::path GetAppDataPath() const override;
|
std::filesystem::path GetAppDataPath() const override;
|
||||||
std::filesystem::path GetTemporaryPath() const override;
|
std::filesystem::path GetTemporaryPath() const override;
|
||||||
|
std::filesystem::path GetLogPath() const override;
|
||||||
|
|
||||||
std::optional<size_t> GetAvailableDiskSpaceInBytes(
|
std::optional<size_t> GetAvailableDiskSpaceInBytes(
|
||||||
const std::filesystem::path& path) const override;
|
const std::filesystem::path& path) const override;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
#define THIRD_PARTY_NEARBY_INTERNAL_TEST_FAKE_DEVICE_INFO_H_
|
#define THIRD_PARTY_NEARBY_INTERNAL_TEST_FAKE_DEVICE_INFO_H_
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <filesystem>
|
#include <filesystem> // NOLINT
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
@@ -63,6 +63,8 @@ class FakeDeviceInfo : public DeviceInfo {
|
|||||||
|
|
||||||
std::filesystem::path GetTemporaryPath() const override { return temp_path_; }
|
std::filesystem::path GetTemporaryPath() const override { return temp_path_; }
|
||||||
|
|
||||||
|
std::filesystem::path GetLogPath() const override { return temp_path_; }
|
||||||
|
|
||||||
std::optional<size_t> GetAvailableDiskSpaceInBytes(
|
std::optional<size_t> GetAvailableDiskSpaceInBytes(
|
||||||
const std::filesystem::path& path) const override {
|
const std::filesystem::path& path) const override {
|
||||||
std::wstring path_key = path.wstring();
|
std::wstring path_key = path.wstring();
|
||||||
|
|||||||
Reference in New Issue
Block a user