diff --git a/dom/quota/ActorsParent.cpp b/dom/quota/ActorsParent.cpp index a4a5fe97c475..84e32fabae0e 100644 --- a/dom/quota/ActorsParent.cpp +++ b/dom/quota/ActorsParent.cpp @@ -2697,33 +2697,14 @@ Result GetTemporaryStorageLimit(nsIFile& aStorageDir) { 1024; } - const int64_t teraByte = 1024 * 1024 * 1024 * 1024; - const auto maxAllowedCapacity = 8 * teraByte; - // Check for disk capacity of user's device on which storage directory lives. - int64_t diskCapacity = maxAllowedCapacity; - - // Log error when default disk capacity is returned due to the error - [&aStorageDir, &diskCapacity]() { - QM_FAIL(aStorageDir.GetDiskCapacity(&diskCapacity)); - }(); + QM_TRY_INSPECT(const int64_t& diskCapacity, + MOZ_TO_RESULT_INVOKE_MEMBER(aStorageDir, GetDiskCapacity)); MOZ_ASSERT(diskCapacity >= 0); // Allow temporary storage to consume up to 50% of disk capacity. - const auto regularCapacityLimit = diskCapacity / 2u; - - // If the disk capacity reported by the operating system is very - // large and potentially incorrect due to hardware issues, - // a hardcoded limit is supplied instead. - auto capacityLimit = maxAllowedCapacity; - - [regularCapacityLimit, maxAllowedCapacity, &capacityLimit]() { - QM_TRY(OkIf(regularCapacityLimit >= maxAllowedCapacity), QM_VOID); - capacityLimit = regularCapacityLimit; - }(); - - return capacityLimit; + return diskCapacity / 2u; } bool IsOriginUnaccessed(const FullOriginMetadata& aFullOriginMetadata, diff --git a/xpcom/io/nsLocalFileUnix.cpp b/xpcom/io/nsLocalFileUnix.cpp index e88565d5659f..321f3a1ff9e7 100644 --- a/xpcom/io/nsLocalFileUnix.cpp +++ b/xpcom/io/nsLocalFileUnix.cpp @@ -1492,11 +1492,14 @@ nsresult nsLocalFile::GetDiskInfo(StatInfoFunc&& aStatInfoFunc, checkedResult = std::forward(aStatInfoFunc)(fs_buf); if (!checkedResult.isValid()) { - return NS_ERROR_CANNOT_CONVERT_DATA; + return NS_ERROR_FAILURE; } - // If we return an error, *aValue will not be modified. - int64_t tentativeResult = checkedResult.value(); + *aResult = checkedResult.value(); + +# ifdef DEBUG_DISK_SPACE + printf("DiskInfo: %lu bytes\n", *aResult); +# endif # if defined(USE_LINUX_QUOTACTL) @@ -1520,21 +1523,15 @@ nsresult nsLocalFile::GetDiskInfo(StatInfoFunc&& aStatInfoFunc, && dq.dqb_bhardlimit) { checkedResult = std::forward(aQuotaInfoFunc)(dq); if (!checkedResult.isValid()) { - return NS_ERROR_CANNOT_CONVERT_DATA; + return NS_ERROR_FAILURE; } - if (checkedResult.value() < tentativeResult) { - tentativeResult = checkedResult.value(); + if (checkedResult.value() < *aResult) { + *aResult = checkedResult.value(); } } # endif -# ifdef DEBUG_DISK_SPACE - printf("DiskInfo: %lu bytes\n", tentativeResult); -# endif - - *aResult = tentativeResult; - return NS_OK; #else diff --git a/xpcom/io/nsLocalFileWin.cpp b/xpcom/io/nsLocalFileWin.cpp index 37278f264d6f..4022af8dc1d0 100644 --- a/xpcom/io/nsLocalFileWin.cpp +++ b/xpcom/io/nsLocalFileWin.cpp @@ -2734,6 +2734,8 @@ nsLocalFile::GetDiskCapacity(int64_t* aDiskCapacity) { return NS_ERROR_INVALID_ARG; } + *aDiskCapacity = 0; + nsresult rv = ResolveAndStat(); if (NS_FAILED(rv)) { return rv;