feat: add CountEntries to skip decryption for list --detail (#562)

* feat: add CountEntries to skip decryption for list --detail (#549)
* test: add CountEntries and countCategory tests at browser level
* fix: address review feedback on CountRows and countLocalStorage
* test: add CountRows unit tests
This commit is contained in:
Roger
2026-04-07 22:28:39 +08:00
committed by GitHub
parent 5f42d4fe5f
commit b3bbc0dadf
40 changed files with 1009 additions and 101 deletions
+2 -30
View File
@@ -58,40 +58,12 @@ func printDetail(out io.Writer, browsers []browser.Browser) error {
fmt.Fprintln(w)
for _, b := range browsers {
data, _ := b.Extract(types.AllCategories)
counts, _ := b.CountEntries(types.AllCategories)
fmt.Fprintf(w, "%s\t%s", b.BrowserName(), b.ProfileName())
for _, c := range types.AllCategories {
fmt.Fprintf(w, "\t%d", countEntries(data, c))
fmt.Fprintf(w, "\t%d", counts[c])
}
fmt.Fprintln(w)
}
return w.Flush()
}
func countEntries(data *types.BrowserData, c types.Category) int {
if data == nil {
return 0
}
switch c {
case types.Password:
return len(data.Passwords)
case types.Cookie:
return len(data.Cookies)
case types.Bookmark:
return len(data.Bookmarks)
case types.History:
return len(data.Histories)
case types.Download:
return len(data.Downloads)
case types.CreditCard:
return len(data.CreditCards)
case types.Extension:
return len(data.Extensions)
case types.LocalStorage:
return len(data.LocalStorage)
case types.SessionStorage:
return len(data.SessionStorage)
default:
return 0
}
}