1
0
mirror of https://github.com/fumiama/dupimage.git synced 2026-06-25 06:09:54 +08:00

add err log

This commit is contained in:
源文雨
2022-07-30 10:51:09 +08:00
parent 0ec4522bee
commit afafc96233

24
main.go
View File

@@ -131,22 +131,25 @@ func main() {
} }
if uint(dis) < throttle { if uint(dis) < throttle {
x, ok := duplis[chklst[j].name] x, ok := duplis[chklst[j].name]
if ok { if ok { // 该图片已被归入其他组
hasfound := false
LOP: LOP:
for k, set := range sameset { for k, set := range sameset {
for _, item := range set { for _, item := range set {
if x == item { if x == item { // 是该图片所属的组
if isfirst { if isfirst { // 首次归类, 直接添加新组
sameset[k] = append(sameset[k], uint(i)) sameset[k] = append(sameset[k], uint(i))
duplis[chklst[i].name] = uint(i) duplis[chklst[i].name] = uint(i)
isfirst = false isfirst = false
hasfound = true
} else { } else {
INNERLOP: INNERLOP:
for l, set := range sameset { for l, set := range sameset {
for _, item := range set { for _, item := range set {
if item == uint(i) { if item == uint(i) { // 找到旧组
sameset[k] = append(sameset[k], set...) sameset[k] = append(sameset[k], set...) // 合并
sameset = append(sameset[:l], sameset[l+1:]...) sameset = append(sameset[:l], sameset[l+1:]...) // 删除
hasfound = true
break INNERLOP break INNERLOP
} }
} }
@@ -156,7 +159,11 @@ func main() {
} }
} }
} }
} else if isfirst { if !hasfound {
fmt.Println("sameset: ", sameset)
panic("index " + strconv.Itoa(j) + ", file " + chklst[j].name + " has been marked as set " + strconv.FormatUint(uint64(x), 10) + " but cannot be found in sameset")
}
} else if isfirst { // 自立新组
sameset = append(sameset, []uint{uint(i)}) sameset = append(sameset, []uint{uint(i)})
duplis[chklst[i].name] = uint(i) duplis[chklst[i].name] = uint(i)
isfirst = false isfirst = false
@@ -176,7 +183,8 @@ func main() {
} }
} }
} }
panic("internal logic error") fmt.Println("sameset: ", sameset)
panic("cannot find index " + strconv.FormatUint(uint64(i), 10) + " in sameset")
} }
for k, v := range duplis { for k, v := range duplis {
i := setindex(v) i := setindex(v)