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