|
|
|
@ -28,7 +28,7 @@ func New(name, storage, profilePath string, items []item.Item) ([]*Chromium, err |
|
|
|
|
profilePath: profilePath, |
|
|
|
|
items: items, |
|
|
|
|
} |
|
|
|
|
multiItemPaths, err := c.getMultiItemPath(c.profilePath, c.items) |
|
|
|
|
multiItemPaths, err := c.userItemPaths(c.profilePath, c.items) |
|
|
|
|
if err != nil { |
|
|
|
|
return nil, err |
|
|
|
|
} |
|
|
|
@ -48,8 +48,13 @@ func (c *Chromium) Name() string { |
|
|
|
|
return c.name |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (c *Chromium) BrowsingData() (*browingdata.Data, error) { |
|
|
|
|
b := browingdata.New(c.items) |
|
|
|
|
func (c *Chromium) BrowsingData(isFullExport bool) (*browingdata.Data, error) { |
|
|
|
|
items := c.items |
|
|
|
|
if !isFullExport { |
|
|
|
|
items = item.FilterSensitiveItems(c.items) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
data := browingdata.New(items) |
|
|
|
|
|
|
|
|
|
if err := c.copyItemToLocal(); err != nil { |
|
|
|
|
return nil, err |
|
|
|
@ -61,10 +66,10 @@ func (c *Chromium) BrowsingData() (*browingdata.Data, error) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
c.masterKey = masterKey |
|
|
|
|
if err := b.Recovery(c.masterKey); err != nil { |
|
|
|
|
if err := data.Recovery(c.masterKey); err != nil { |
|
|
|
|
return nil, err |
|
|
|
|
} |
|
|
|
|
return b, nil |
|
|
|
|
return data, nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (c *Chromium) copyItemToLocal() error { |
|
|
|
@ -72,7 +77,7 @@ func (c *Chromium) copyItemToLocal() error { |
|
|
|
|
filename := i.String() |
|
|
|
|
var err error |
|
|
|
|
switch { |
|
|
|
|
case fileutil.FolderExists(path): |
|
|
|
|
case fileutil.IsDirExists(path): |
|
|
|
|
if i == item.ChromiumLocalStorage { |
|
|
|
|
err = fileutil.CopyDir(path, filename, "lock") |
|
|
|
|
} |
|
|
|
@ -89,8 +94,8 @@ func (c *Chromium) copyItemToLocal() error { |
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (c *Chromium) getMultiItemPath(profilePath string, items []item.Item) (map[string]map[item.Item]string, error) { |
|
|
|
|
// multiItemPaths is a map of user to item path, map[profile 1][item's name & path key pair]
|
|
|
|
|
// userItemPaths return a map of user to item path, map[profile 1][item's name & path key pair]
|
|
|
|
|
func (c *Chromium) userItemPaths(profilePath string, items []item.Item) (map[string]map[item.Item]string, error) { |
|
|
|
|
multiItemPaths := make(map[string]map[item.Item]string) |
|
|
|
|
parentDir := fileutil.ParentDir(profilePath) |
|
|
|
|
err := filepath.Walk(parentDir, chromiumWalkFunc(items, multiItemPaths)) |
|
|
|
@ -120,6 +125,7 @@ func (c *Chromium) getMultiItemPath(profilePath string, items []item.Item) (map[ |
|
|
|
|
return t, nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// chromiumWalkFunc return a filepath.WalkFunc to find item's path
|
|
|
|
|
func chromiumWalkFunc(items []item.Item, multiItemPaths map[string]map[item.Item]string) filepath.WalkFunc { |
|
|
|
|
return func(path string, info fs.FileInfo, err error) error { |
|
|
|
|
for _, v := range items { |
|
|
|
@ -145,7 +151,7 @@ func chromiumWalkFunc(items []item.Item, multiItemPaths map[string]map[item.Item |
|
|
|
|
func fillLocalStoragePath(itemPaths map[item.Item]string, storage item.Item) { |
|
|
|
|
if p, ok := itemPaths[item.ChromiumHistory]; ok { |
|
|
|
|
lsp := filepath.Join(filepath.Dir(p), storage.FileName()) |
|
|
|
|
if fileutil.FolderExists(lsp) { |
|
|
|
|
if fileutil.IsDirExists(lsp) { |
|
|
|
|
itemPaths[item.ChromiumLocalStorage] = lsp |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|