|
|
|
@ -71,16 +71,21 @@ func (c *chromium) BrowsingData() (*browingdata.Data, error) { |
|
|
|
|
|
|
|
|
|
func (c *chromium) copyItemToLocal() error { |
|
|
|
|
for i, path := range c.itemPaths { |
|
|
|
|
// var dstFilename = item.TempName()
|
|
|
|
|
var filename = i.String() |
|
|
|
|
// TODO: Handle read file error
|
|
|
|
|
d, err := ioutil.ReadFile(path) |
|
|
|
|
if err != nil { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
err = ioutil.WriteFile(filename, d, 0777) |
|
|
|
|
if err != nil { |
|
|
|
|
return err |
|
|
|
|
if fileutil.FolderExists(path) { |
|
|
|
|
if err := fileutil.CopyDir(path, i.String()); err != nil { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
var filename = i.String() |
|
|
|
|
// TODO: Handle read file error
|
|
|
|
|
d, err := ioutil.ReadFile(path) |
|
|
|
|
if err != nil { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
err = ioutil.WriteFile(filename, d, 0777) |
|
|
|
|
if err != nil { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return nil |
|
|
|
@ -91,7 +96,11 @@ func (c *chromium) getItemPath(profilePath string, items []item.Item) (map[item. |
|
|
|
|
parentDir := fileutil.ParentDir(profilePath) |
|
|
|
|
baseDir := fileutil.BaseDir(profilePath) |
|
|
|
|
err := filepath.Walk(parentDir, chromiumWalkFunc(items, itemPaths, baseDir)) |
|
|
|
|
return itemPaths, err |
|
|
|
|
if err != nil { |
|
|
|
|
return itemPaths, err |
|
|
|
|
} |
|
|
|
|
fillLocalStoragePath(itemPaths, item.ChromiumLocalStorage) |
|
|
|
|
return itemPaths, nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func chromiumWalkFunc(items []item.Item, itemPaths map[item.Item]string, baseDir string) filepath.WalkFunc { |
|
|
|
@ -110,3 +119,12 @@ func chromiumWalkFunc(items []item.Item, itemPaths map[item.Item]string, baseDir |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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) { |
|
|
|
|
itemPaths[item.ChromiumLocalStorage] = lsp |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|