From 5e3844390f800c8ef8213f656f99befdd741f255 Mon Sep 17 00:00:00 2001
From: jessopb <36554050+jessopb@users.noreply.github.com>
Date: Wed, 15 Dec 2021 18:11:22 -0500
Subject: [PATCH] update disk space setting to new api (#7356)
---
static/app-strings.json | 9 +++
ui/component/settingSystem/view.jsx | 111 ++++++++++++++++++++--------
ui/constants/daemon_settings.js | 1 +
3 files changed, 89 insertions(+), 32 deletions(-)
diff --git a/static/app-strings.json b/static/app-strings.json
index daa35ab0a..515bb7550 100644
--- a/static/app-strings.json
+++ b/static/app-strings.json
@@ -2226,5 +2226,14 @@
"This is information like error logging, performance tracking, and usage statistics. It includes your IP address and basic system details, but no other identifying information (unless you connect to a cloud service)": "This is information like error logging, performance tracking, and usage statistics. It includes your IP address and basic system details, but no other identifying information (unless you connect to a cloud service)",
"Use official LBRY wallet servers": "Use official LBRY wallet servers",
"Enable Prerelease Updates": "Enable Prerelease Updates",
+ "Enable Upgrade to Test Builds": "Enable Upgrade to Test Builds",
+ "Prereleases may break things and we may not be able to fix them for you.": "Prereleases may break things and we may not be able to fix them for you.",
+ "Limit (GB)": "Limit (GB)",
+ "Limit Hosting for Content you Use": "Limit Hosting for Content you Use",
+ "Allow (GB)": "Allow (GB)",
+ "Content Data Hosting helps to seed things that you watch and download.": "Content Data Hosting helps to seed things that you watch and download.",
+ "Network Data Hosting allows the p2p network to store blobs unrelated to your browsing.": "Network Data Hosting allows the p2p network to store blobs unrelated to your browsing.",
+ "Content: Limit (GB)": "Content: Limit (GB)",
+ "Network: Allow (GB)": "Network: Allow (GB)",
"--end--": "--end--"
}
diff --git a/ui/component/settingSystem/view.jsx b/ui/component/settingSystem/view.jsx
index 617b60905..0e787c520 100644
--- a/ui/component/settingSystem/view.jsx
+++ b/ui/component/settingSystem/view.jsx
@@ -41,8 +41,11 @@ type DaemonSettings = {
type DaemonStatus = {
disk_space: {
- running: boolean,
- space_used: string,
+ content_blobs_storage_used_mb: string,
+ published_blobs_storage_used_mb: string,
+ running: true,
+ seed_blobs_storage_used_mb: string,
+ total_used_mb: string,
},
};
@@ -90,10 +93,16 @@ export default function SettingSystem(props: Props) {
const [clearingCache, setClearingCache] = React.useState(false);
const [storedPassword, setStoredPassword] = React.useState(false);
const { disk_space } = daemonStatus;
- const spaceUsed = Number(disk_space.space_used);
+ const contentSpaceUsed = Number(disk_space.content_blobs_storage_used_mb);
+ const networkSpaceUsed = Number(disk_space.seed_blobs_storage_used_mb);
const blobLimitSetting = daemonSettings[DAEMON_SETTINGS.BLOB_STORAGE_LIMIT_MB];
- const [blobSpaceLimitGB, setBlobSpaceLimit] = React.useState(blobLimitSetting ? blobLimitSetting / 1024 : 0);
- // const debouncedBlobSpaceLimitGB = useDebounce(blobSpaceLimitGB || 0, 500);
+ const networkLimitSetting = daemonSettings[DAEMON_SETTINGS.NETWORK_STORAGE_LIMIT_MB];
+ const [contentBlobSpaceLimitGB, setContentBlobSpaceLimit] = React.useState(
+ blobLimitSetting ? blobLimitSetting / 1024 : 0
+ );
+ const [networkBlobSpaceLimitGB, setNetworkBlobSpaceLimit] = React.useState(
+ networkLimitSetting ? networkLimitSetting / 1024 : 0
+ );
const [limitSpace, setLimitSpace] = React.useState(Boolean(blobLimitSetting));
const { available: ffmpegAvailable, which: ffmpegPath } = ffmpegStatus;
@@ -109,11 +118,19 @@ export default function SettingSystem(props: Props) {
confirmForgetPassword({ callback: () => setStoredPassword(false) });
}
- function updateBlobLimitField(gb) {
+ function updateContentBlobLimitField(gb) {
if (gb === 0) {
- setBlobSpaceLimit(0);
+ setContentBlobSpaceLimit(0);
} else if (!gb || !isNaN(gb)) {
- setBlobSpaceLimit(gb);
+ setContentBlobSpaceLimit(gb);
+ }
+ }
+
+ function updateNetworkBlobLimitField(gb) {
+ if (gb === 0) {
+ setNetworkBlobSpaceLimit(0);
+ } else if (!gb || !isNaN(gb)) {
+ setNetworkBlobSpaceLimit(gb);
}
}
@@ -122,18 +139,25 @@ export default function SettingSystem(props: Props) {
if (!value) {
setDaemonSetting(DAEMON_SETTINGS.BLOB_STORAGE_LIMIT_MB, String(0));
} else {
- const spaceLimitMB = blobSpaceLimitGB * 1024;
+ const spaceLimitMB = contentBlobSpaceLimitGB * 1024;
setDaemonSetting(DAEMON_SETTINGS.BLOB_STORAGE_LIMIT_MB, String(spaceLimitMB));
}
}
- function handleSetBlobSpaceLimit() {
- const spaceLimitMB = blobSpaceLimitGB * 1024;
+ function handleSetContentBlobSpaceLimit() {
+ const spaceLimitMB = contentBlobSpaceLimitGB * 1024;
if (!isNaN(spaceLimitMB) && blobLimitSetting !== spaceLimitMB * 1024) {
setDaemonSetting(DAEMON_SETTINGS.BLOB_STORAGE_LIMIT_MB, String(spaceLimitMB));
}
}
+ function handleSetNetworkBlobSpaceLimit() {
+ const spaceLimitMB = networkBlobSpaceLimitGB * 1024;
+ if (!isNaN(spaceLimitMB) && blobLimitSetting !== spaceLimitMB * 1024) {
+ setDaemonSetting(DAEMON_SETTINGS.NETWORK_STORAGE_LIMIT_MB, String(spaceLimitMB));
+ }
+ }
+
// Update ffmpeg variables
React.useEffect(() => {
const { available } = ffmpegStatus;
@@ -198,16 +222,23 @@ export default function SettingSystem(props: Props) {
multirow
subtitle={
+ {__('Content Data Hosting helps to seed things that you watch and download.')}{' '}
+ {__('Network Data Hosting allows the p2p network to store blobs unrelated to your browsing.')}{' '}
{__("If disabled, LBRY will be very sad and you won't be helping improve the network.")}{' '}
{__('If you set a limit, playing videos may exceed your limit until cleanup runs every 30 minutes.')}{' '}
.
- {`Using ${formatBytes(spaceUsed * BYTES_PER_MB)} of ${
+ {`Content Hosting using ${formatBytes(contentSpaceUsed * BYTES_PER_MB)} of ${
daemonSettings[DAEMON_SETTINGS.BLOB_STORAGE_LIMIT_MB]
? formatBytes(daemonSettings[DAEMON_SETTINGS.BLOB_STORAGE_LIMIT_MB] * BYTES_PER_MB)
: 'Unlimited'
}`}
+
+ {`Network Hosting using ${formatBytes(networkSpaceUsed * BYTES_PER_MB)} of ${formatBytes(
+ daemonSettings[DAEMON_SETTINGS.NETWORK_STORAGE_LIMIT_MB] * BYTES_PER_MB
+ )}`}
+