Files & Sizes explorer: browse Depot & Workspace as a tree with per-file/folder weight
- Backend depot_ls (p4 dirs + p4 sizes -s recursive summary per child + p4 sizes for direct files) and fs_ls (local recursive folder sizing), both confined - Tools -> Files & Sizes: Depot/Workspace tabs, lazy-loading tree, size bars, heaviest-first sort, folder file counts, open-in-explorer - humanSize() helper + FsEntry type; i18n in 5 languages Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
13
src/p4.ts
13
src/p4.ts
@ -74,6 +74,8 @@ export const p4 = {
|
||||
filelog: (depot: string) => invoke<Record<string, unknown>>("p4_filelog", { depot }),
|
||||
cleanPreview: (scope = "") => invoke<OpenedFile[]>("p4_clean_preview", { scope }),
|
||||
cleanApply: (scope = "") => invoke<string>("p4_clean_apply", { scope }),
|
||||
depotLs: (path = "") => invoke<FsEntry[]>("depot_ls", { path }),
|
||||
fsLs: (path = "") => invoke<FsEntry[]>("fs_ls", { path }),
|
||||
reconcilePreview: (scope = "") => invoke<OpenedFile[]>("p4_reconcile_preview", { scope }),
|
||||
reconcileApply: (paths: string[]) => invoke<OpenedFile[]>("p4_reconcile_apply", { paths }),
|
||||
setWritable: (paths: string[], writable: boolean) => invoke<string>("p4_set_writable", { paths, writable }),
|
||||
@ -191,6 +193,17 @@ export function leaf(path?: string): string {
|
||||
|
||||
// per-file revision history parsed from p4 filelog's indexed fields
|
||||
export interface FileRev { rev: string; change: string; action: string; user: string; time: string; desc: string; type: string }
|
||||
/** One entry (file or folder) in the Depot/Workspace size explorer. `size` is bytes. */
|
||||
export interface FsEntry { name: string; path: string; isDir: boolean; size: number; fileCount: number }
|
||||
/** Human-readable byte size, e.g. 1536 → "1.5 KB". */
|
||||
export function humanSize(n: number): string {
|
||||
if (!n) return "0 B";
|
||||
if (n < 1024) return `${n} B`;
|
||||
const u = ["KB", "MB", "GB", "TB", "PB"];
|
||||
let v = n, i = -1;
|
||||
do { v /= 1024; i++; } while (v >= 1024 && i < u.length - 1);
|
||||
return `${v >= 100 ? Math.round(v) : v.toFixed(1)} ${u[i]}`;
|
||||
}
|
||||
export function filelogRevs(v: Record<string, unknown>): FileRev[] {
|
||||
const out: FileRev[] = [];
|
||||
for (let i = 0; ; i++) {
|
||||
|
||||
Reference in New Issue
Block a user