goduf.go
changeset 15 4e3a67dc70a0
parent 14 ea4286b6c4b1
child 16 cc0ee80cf216
equal deleted inserted replaced
14:ea4286b6c4b1 15:4e3a67dc70a0
   284 			myLog.Println(0, "Error:", err)
   284 			myLog.Println(0, "Error:", err)
   285 		}
   285 		}
   286 	}
   286 	}
   287 }
   287 }
   288 
   288 
   289 
       
   290 func (fileList FileObjList) scheduleChecksum(sType sumType) {
   289 func (fileList FileObjList) scheduleChecksum(sType sumType) {
   291 	for _, fo := range fileList {
   290 	for _, fo := range fileList {
   292 		fo.needHash = sType
   291 		fo.needHash = sType
   293 	}
   292 	}
   294 }
   293 }
   318 		}
   317 		}
   319 		if sType == partialChecksum {
   318 		if sType == partialChecksum {
   320 			scheduleFull = append(scheduleFull, l)
   319 			scheduleFull = append(scheduleFull, l)
   321 		} else { // full checksums -> we're done
   320 		} else { // full checksums -> we're done
   322 			dupeList = append(dupeList, l)
   321 			dupeList = append(dupeList, l)
   323 			// TODO: sort by increasing size
       
   324 			myLog.Printf(5, "  . found %d new duplicates\n", len(l))
   322 			myLog.Printf(5, "  . found %d new duplicates\n", len(l))
   325 		}
   323 		}
   326 	}
   324 	}
   327 	if sType == partialChecksum && len(scheduleFull) > 0 {
   325 	if sType == partialChecksum && len(scheduleFull) > 0 {
   328 		computeSheduledChecksums(scheduleFull)
   326 		computeSheduledChecksums(scheduleFull)
   360 	}
   358 	}
   361 	for _, l := range scheduleFull {
   359 	for _, l := range scheduleFull {
   362 		r := l.findDupesChecksums(fullChecksum)
   360 		r := l.findDupesChecksums(fullChecksum)
   363 		dupeList = append(dupeList, r...)
   361 		dupeList = append(dupeList, r...)
   364 	}
   362 	}
   365 	// TODO: sort by increasing size
       
   366 	return dupeList
   363 	return dupeList
   367 }
   364 }
   368 
   365 
   369 func (data *dataT) dropEmptyFiles(ignoreEmpty bool) (emptyCount int) {
   366 func (data *dataT) dropEmptyFiles(ignoreEmpty bool) (emptyCount int) {
   370 	sgListP, ok := data.sizeGroups[0]
   367 	sgListP, ok := data.sizeGroups[0]
   404 		// Remove unique dev/inodes
   401 		// Remove unique dev/inodes
   405 		// Instead of this loop, another way would be to use the field
   402 		// Instead of this loop, another way would be to use the field
   406 		// "Unique" of the fileObj to mark them to be discarded
   403 		// "Unique" of the fileObj to mark them to be discarded
   407 		// and remove them all at the end.
   404 		// and remove them all at the end.
   408 		for {
   405 		for {
   409 			type devinode struct { dev, ino uint64 }
   406 			type devinode struct{ dev, ino uint64 }
   410 			devinodes := make(map[devinode]bool)
   407 			devinodes := make(map[devinode]bool)
   411 			var hardLinkIndex int
   408 			var hardLinkIndex int
   412 
   409 
   413 			for i, fo := range *sgListP {
   410 			for i, fo := range *sgListP {
   414 				dev, ino := GetDevIno(fo)
   411 				dev, ino := GetDevIno(fo)
   415 				di := devinode{ dev, ino}
   412 				di := devinode{dev, ino}
   416 				if _, hlink := devinodes[di]; hlink {
   413 				if _, hlink := devinodes[di]; hlink {
   417 					hardLinkIndex = i
   414 					hardLinkIndex = i
   418 					hardLinkCount++
   415 					hardLinkCount++
   419 					hardlinksFound = true
   416 					hardlinksFound = true
   420 					break
   417 					break
   558 
   555 
   559 	// Done!  Dump dupes
   556 	// Done!  Dump dupes
   560 	if len(result) > 0 && !summary {
   557 	if len(result) > 0 && !summary {
   561 		myLog.Println(1, "* Dupes:")
   558 		myLog.Println(1, "* Dupes:")
   562 	}
   559 	}
       
   560 	// TODO: sort by increasing size
   563 	var dupeSize uint64
   561 	var dupeSize uint64
   564 	data.cmpt = 0
   562 	data.cmpt = 0
   565 	for i, l := range result {
   563 	for i, l := range result {
   566 		size := uint64(l[0].Size())
   564 		size := uint64(l[0].Size())
   567 		// We do not count the size of the 1st item
   565 		// We do not count the size of the 1st item