@@ -71,16 +71,21 @@ func (c *chromium) BrowsingData() (*browingdata.Data, error) {
7171
7272func (c * chromium ) copyItemToLocal () error {
7373 for i , path := range c .itemPaths {
74- // var dstFilename = item.TempName()
75- var filename = i .String ()
76- // TODO: Handle read file error
77- d , err := ioutil .ReadFile (path )
78- if err != nil {
79- return err
80- }
81- err = ioutil .WriteFile (filename , d , 0777 )
82- if err != nil {
83- return err
74+ if fileutil .FolderExists (path ) {
75+ if err := fileutil .CopyDir (path , i .String ()); err != nil {
76+ return err
77+ }
78+ } else {
79+ var filename = i .String ()
80+ // TODO: Handle read file error
81+ d , err := ioutil .ReadFile (path )
82+ if err != nil {
83+ return err
84+ }
85+ err = ioutil .WriteFile (filename , d , 0777 )
86+ if err != nil {
87+ return err
88+ }
8489 }
8590 }
8691 return nil
@@ -91,7 +96,11 @@ func (c *chromium) getItemPath(profilePath string, items []item.Item) (map[item.
9196 parentDir := fileutil .ParentDir (profilePath )
9297 baseDir := fileutil .BaseDir (profilePath )
9398 err := filepath .Walk (parentDir , chromiumWalkFunc (items , itemPaths , baseDir ))
94- return itemPaths , err
99+ if err != nil {
100+ return itemPaths , err
101+ }
102+ fillLocalStoragePath (itemPaths , item .ChromiumLocalStorage )
103+ return itemPaths , nil
95104}
96105
97106func 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
110119 return err
111120 }
112121}
122+
123+ func fillLocalStoragePath (itemPaths map [item.Item ]string , storage item.Item ) {
124+ if p , ok := itemPaths [item .ChromiumHistory ]; ok {
125+ lsp := filepath .Join (filepath .Dir (p ), storage .FileName ())
126+ if fileutil .FolderExists (lsp ) {
127+ itemPaths [item .ChromiumLocalStorage ] = lsp
128+ }
129+ }
130+ }
0 commit comments