diff --git a/backend/handlers/sharing.go b/backend/handlers/sharing.go
index 8df9572..e492b45 100644
--- a/backend/handlers/sharing.go
+++ b/backend/handlers/sharing.go
@@ -229,9 +229,25 @@ func (h *ShareHandler) GetPublicShare(c *fiber.Ctx) error {
mimeType = "application/octet-stream"
}
+ getDirSize := func(p string) int64 {
+ var s int64
+ filepath.Walk(p, func(_ string, i os.FileInfo, err error) error {
+ if err == nil && !i.IsDir() {
+ s += i.Size()
+ }
+ return nil
+ })
+ return s
+ }
+
+ size := info.Size()
+ if info.IsDir() {
+ size = getDirSize(fullPath)
+ }
+
response := fiber.Map{
"name": info.Name(), // Use info.Name() instead of base of original path
- "size": info.Size(),
+ "size": size,
"is_dir": info.IsDir(),
"mime_type": mimeType,
}
@@ -249,9 +265,13 @@ func (h *ShareHandler) GetPublicShare(c *fiber.Ctx) error {
if eMime == "" {
eMime = "application/octet-stream"
}
+ entrySize := entryInfo.Size()
+ if entry.IsDir() {
+ entrySize = getDirSize(filepath.Join(fullPath, entry.Name()))
+ }
files = append(files, fiber.Map{
"name": entry.Name(),
- "size": entryInfo.Size(),
+ "size": entrySize,
"is_dir": entry.IsDir(),
"mime_type": eMime,
})
diff --git a/frontend/src/app/share/[id]/page.tsx b/frontend/src/app/share/[id]/page.tsx
index e327536..02a0263 100644
--- a/frontend/src/app/share/[id]/page.tsx
+++ b/frontend/src/app/share/[id]/page.tsx
@@ -247,7 +247,7 @@ export default function PublicSharePage({ params }: { params: Promise<{ id: stri
className="flex items-center gap-2 px-5 py-2.5 rounded-xl font-medium transition-all hover:bg-white/10 bg-white/5 border border-white/10 text-white shadow-lg"
>