Skip to content

Commit 511f71f

Browse files
committed
refactor: remove get single user item path
1 parent 6d710c2 commit 511f71f

1 file changed

Lines changed: 2 additions & 32 deletions

File tree

internal/browser/chromium/chromium.go

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package chromium
22

33
import (
44
"io/fs"
5-
"os"
65
"path/filepath"
76
"strings"
87

@@ -90,23 +89,11 @@ func (c *chromium) copyItemToLocal() error {
9089
return nil
9190
}
9291

93-
func (c *chromium) getItemPath(profilePath string, items []item.Item) (map[item.Item]string, error) {
94-
itemPaths := make(map[item.Item]string)
95-
parentDir := fileutil.ParentDir(profilePath)
96-
baseDir := fileutil.BaseDir(profilePath)
97-
err := filepath.Walk(parentDir, chromiumWalkFunc(items, itemPaths, baseDir))
98-
if err != nil {
99-
return itemPaths, err
100-
}
101-
fillLocalStoragePath(itemPaths, item.ChromiumLocalStorage)
102-
return itemPaths, nil
103-
}
104-
10592
func (c *chromium) getMultiItemPath(profilePath string, items []item.Item) (map[string]map[item.Item]string, error) {
10693
// multiItemPaths is a map of user to item path, map[profile 1][item's name & path key pair]
10794
multiItemPaths := make(map[string]map[item.Item]string)
10895
parentDir := fileutil.ParentDir(profilePath)
109-
err := filepath.Walk(parentDir, chromiumWalkFunc2(items, multiItemPaths))
96+
err := filepath.Walk(parentDir, chromiumWalkFunc(items, multiItemPaths))
11097
if err != nil {
11198
return nil, err
11299
}
@@ -133,7 +120,7 @@ func (c *chromium) getMultiItemPath(profilePath string, items []item.Item) (map[
133120
return t, nil
134121
}
135122

136-
func chromiumWalkFunc2(items []item.Item, multiItemPaths map[string]map[item.Item]string) filepath.WalkFunc {
123+
func chromiumWalkFunc(items []item.Item, multiItemPaths map[string]map[item.Item]string) filepath.WalkFunc {
137124
return func(path string, info fs.FileInfo, err error) error {
138125
for _, v := range items {
139126
if info.Name() == v.FileName() {
@@ -152,23 +139,6 @@ func chromiumWalkFunc2(items []item.Item, multiItemPaths map[string]map[item.Ite
152139
}
153140
}
154141

155-
func chromiumWalkFunc(items []item.Item, itemPaths map[item.Item]string, baseDir string) filepath.WalkFunc {
156-
return func(path string, info os.FileInfo, err error) error {
157-
for _, it := range items {
158-
switch {
159-
case it.FileName() == info.Name():
160-
if it == item.ChromiumKey {
161-
itemPaths[it] = path
162-
}
163-
if strings.Contains(path, baseDir) {
164-
itemPaths[it] = path
165-
}
166-
}
167-
}
168-
return err
169-
}
170-
}
171-
172142
func fillLocalStoragePath(itemPaths map[item.Item]string, storage item.Item) {
173143
if p, ok := itemPaths[item.ChromiumHistory]; ok {
174144
lsp := filepath.Join(filepath.Dir(p), storage.FileName())

0 commit comments

Comments
 (0)