goduf.go
changeset 12 15e3580cfb8d
parent 10 1ee01b135e0e
child 13 4102e5551e1b
equal deleted inserted replaced
11:47e45453b705 12:15e3580cfb8d
   420 		// Remove unique dev/inodes
   420 		// Remove unique dev/inodes
   421 		// Instead of this loop, another way would be to use the field
   421 		// Instead of this loop, another way would be to use the field
   422 		// "Unique" of the fileObj to mark them to be discarded
   422 		// "Unique" of the fileObj to mark them to be discarded
   423 		// and remove them all at the end.
   423 		// and remove them all at the end.
   424 		for {
   424 		for {
       
   425 			type devinode struct { dev, ino uint64 }
       
   426 			devinodes := make(map[devinode]bool)
   425 			var hardLinkIndex int
   427 			var hardLinkIndex int
   426 			fo := sizeGroup.files[0]
   428 
   427 			prevDev, prevIno := GetDevIno(fo)
   429 			for i, fo := range sizeGroup.files {
   428 
       
   429 			for i, fo := range sizeGroup.files[1:] {
       
   430 				dev, ino := GetDevIno(fo)
   430 				dev, ino := GetDevIno(fo)
   431 				if dev == prevDev && ino == prevIno {
   431 				di := devinode{ dev, ino}
   432 					hardLinkIndex = i + 1
   432 				if _, hlink := devinodes[di]; hlink {
       
   433 					hardLinkIndex = i
   433 					hardLinkCount++
   434 					hardLinkCount++
   434 					hardlinksFound = true
   435 					hardlinksFound = true
   435 					break
   436 					break
       
   437 				} else {
       
   438 					devinodes[di] = true
   436 				}
   439 				}
   437 				prevDev = dev
       
   438 				prevIno = ino
       
   439 			}
   440 			}
   440 
   441 
   441 			if hardLinkIndex == 0 {
   442 			if hardLinkIndex == 0 {
   442 				break
   443 				break
   443 			}
   444 			}