Skip to content

Build your personal knowledge base with Trilium Notes

fix(resources): show each resource's space on disk in the options

Elian Dorane598a348b1e7
diff --git a/apps/client/src/widgets/type_widgets/options/resources.spec.tsx b/apps/client/src/widgets/type_widgets/options/resources.spec.tsx
index e3231a1d8f..ab22938059 100644
--- a/apps/client/src/widgets/type_widgets/options/resources.spec.tsx
+++ b/apps/client/src/widgets/type_widgets/options/resources.spec.tsx
@@ -130,7 +130,7 @@ describe("ResourcesSettings", () => {
`resources_options.partially_downloaded {"downloaded":"4.00 MiB","size":"10 MiB"}`
]);
expect([ ...host.querySelectorAll(".resources-size") ].map((size) => size.textContent))
- .toEqual([ "2.00 GiB", "0.01 GiB", "2.00 GiB" ]);
+ .toEqual([ "2.00 GiB", "<0.01 GiB", "2.00 GiB" ]);
expect(rows[0].querySelector(".resource-download-author")?.getAttribute("href"))
.toBe("https://example.com/model");
expect(rows[0].querySelector(".resource-download-license")?.getAttribute("href"))
@@ -140,6 +140,8 @@ describe("ResourcesSettings", () => {
it("lists files copied in but not yet checked, and counts them in the space used", async () => {
mocks.resources = [ resource({ id: "test.copied", unverifiedSize: 6 * MIB }) ];
await open();
+ expect([ ...host.querySelectorAll(".resources-size") ].map((size) => size.textContent))
+ .toEqual([ "6.00 MiB", "6.00 MiB" ]);
const rows = [ ...host.querySelectorAll(".resources-item") ];
expect(rows.map((row) => row.querySelector(".tn-card-option-title")?.textContent))
diff --git a/apps/client/src/widgets/type_widgets/options/resources.tsx b/apps/client/src/widgets/type_widgets/options/resources.tsx
index 118f8fff2a..bad469b5e4 100644
--- a/apps/client/src/widgets/type_widgets/options/resources.tsx
+++ b/apps/client/src/widgets/type_widgets/options/resources.tsx
@@ -136,7 +136,7 @@ function ResourceRow({ resource, unitOf, onDeleted }: ResourceRowProps) {
<EntryRow
icon={resource.icon}
title={resource.title}
- size={formatSize(resource.size, 2, unitOf)}
+ size={formatSize(getSizeOnDisk(resource), 2, unitOf)}
status={getStatusText(resource)}
onOpen={directory ? () => void openService.openDirectory(directory) : undefined}
onDelete={() => void remove()}
diff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Installation & Setup/Downloaded resources.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Installation & Setup/Downloaded resources.html
index eb9bde1597..34c379c41b 100644
--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Installation & Setup/Downloaded resources.html
+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Installation & Setup/Downloaded resources.html
@@ -67,8 +67,9 @@ class="admonition note">
<h2>Managing downloaded resources</h2>
<p>To see the downloaded resources, go to <a class="reference-link" href="#root/_help_4TIF1oA4VQRO">Options</a> → <em>Downloaded resources</em>.
Each resource that was downloaded, or partly downloaded by an interrupted
- download, is listed with its size and its status. Below the list, <em>Space used</em> shows
- the space they take in total, and how much free space is left on the disk.</p>
+ download, is listed with the space it takes on the disk and its status.
+ Below the list, <em>Space used</em> shows the space they take in total, and
+ how much free space is left on the disk.</p>
<ul>
<li>To open the folder of a resource, press the <span class="tn-icon bx bx-folder-open"></span> button
(desktop only).</li>
diff --git a/docs/User Guide/User Guide/Installation & Setup/Downloaded resources.md b/docs/User Guide/User Guide/Installation & Setup/Downloaded resources.md
index 99c7430c4d..feefb057c5 100644
--- a/docs/User Guide/User Guide/Installation & Setup/Downloaded resources.md
+++ b/docs/User Guide/User Guide/Installation & Setup/Downloaded resources.md
@@ -25,7 +25,7 @@ Every file is checked against a checksum built into Trilium before it is used, s
## Managing downloaded resources
-To see the downloaded resources, go to <a class="reference-link" href="../Basic%20Concepts%20and%20Features/UI%20Elements/Options.md">Options</a> → _Downloaded resources_. Each resource that was downloaded, or partly downloaded by an interrupted download, is listed with its size and its status. Below the list, _Space used_ shows the space they take in total, and how much free space is left on the disk.
+To see the downloaded resources, go to <a class="reference-link" href="../Basic%20Concepts%20and%20Features/UI%20Elements/Options.md">Options</a> → _Downloaded resources_. Each resource that was downloaded, or partly downloaded by an interrupted download, is listed with the space it takes on the disk and its status. Below the list, _Space used_ shows the space they take in total, and how much free space is left on the disk.
* To open the folder of a resource, press the <span class="tn-icon bx bx-folder-open"></span> button (desktop only).
* To delete a resource, press the <span class="tn-icon bx bx-trash"></span> button. If a feature needs it again, it is downloaded again.