mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-07-04 21:37:47 +02:00
refactor(archive): rename BuildArchive to WriteArchive
It writes a zip and returns a count; Build prefix clashed with BuildDump, which constructs an in-memory value with no I/O.
This commit is contained in:
+2
-2
@@ -19,11 +19,11 @@ type Archivable interface {
|
|||||||
ArchiveSources(categories []types.Category) []chromium.ArchiveSource
|
ArchiveSources(categories []types.Category) []chromium.ArchiveSource
|
||||||
}
|
}
|
||||||
|
|
||||||
// BuildArchive packs each browser's decryption-relevant files into a zip whose internal layout is
|
// WriteArchive packs each browser's decryption-relevant files into a zip whose internal layout is
|
||||||
// <browser-key>/<User Data layout>, so a restore can re-expand it and decrypt with a keys.json. Files
|
// <browser-key>/<User Data layout>, so a restore can re-expand it and decrypt with a keys.json. Files
|
||||||
// are staged through a locked-file session first because Windows holds exclusive SQLite locks. Returns
|
// are staged through a locked-file session first because Windows holds exclusive SQLite locks. Returns
|
||||||
// the number of source entries staged (a directory source counts once).
|
// the number of source entries staged (a directory source counts once).
|
||||||
func BuildArchive(browsers []Browser, categories []types.Category, outPath string) (int, error) {
|
func WriteArchive(browsers []Browser, categories []types.Category, outPath string) (int, error) {
|
||||||
session, err := filemanager.NewSession()
|
session, err := filemanager.NewSession()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ import (
|
|||||||
"github.com/moond4rk/hackbrowserdata/utils/fileutil"
|
"github.com/moond4rk/hackbrowserdata/utils/fileutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestBuildArchive_RoundTrip exercises the archive path: ArchiveSources -> BuildArchive (stage+zip)
|
// TestWriteArchive_RoundTrip exercises the archive path: ArchiveSources -> WriteArchive (stage+zip)
|
||||||
// -> Unzip, asserting the archive's internal layout is <key>/<User Data layout>.
|
// -> Unzip, asserting the archive's internal layout is <key>/<User Data layout>.
|
||||||
func TestBuildArchive_RoundTrip(t *testing.T) {
|
func TestWriteArchive_RoundTrip(t *testing.T) {
|
||||||
origin := t.TempDir()
|
origin := t.TempDir()
|
||||||
def := filepath.Join(origin, "Default")
|
def := filepath.Join(origin, "Default")
|
||||||
if err := os.MkdirAll(def, 0o755); err != nil {
|
if err := os.MkdirAll(def, 0o755); err != nil {
|
||||||
@@ -34,12 +34,12 @@ func TestBuildArchive_RoundTrip(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
zipPath := filepath.Join(t.TempDir(), "data.zip")
|
zipPath := filepath.Join(t.TempDir(), "data.zip")
|
||||||
n, err := BuildArchive([]Browser{b}, []types.Category{types.History}, zipPath)
|
n, err := WriteArchive([]Browser{b}, []types.Category{types.History}, zipPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("BuildArchive: %v", err)
|
t.Fatalf("WriteArchive: %v", err)
|
||||||
}
|
}
|
||||||
if n == 0 {
|
if n == 0 {
|
||||||
t.Fatal("BuildArchive captured 0 files")
|
t.Fatal("WriteArchive captured 0 entries")
|
||||||
}
|
}
|
||||||
|
|
||||||
extracted := t.TempDir()
|
extracted := t.TempDir()
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ func archiveCmd() *cobra.Command {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
n, err := browser.BuildArchive(browsers, categories, outputPath)
|
n, err := browser.WriteArchive(browsers, categories, outputPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user