func compareRegularFile(request *subproto.UpdateRequest, state *state, subEntry interface{}, requiredRegularFile *filesystem.RegularFile, parentName string) { debugFilename := path.Join(parentName, requiredRegularFile.Name) if subRegularFile, ok := subEntry.(*filesystem.RegularFile); ok { if requiredInode, ok := state.subInodeToRequiredInode[subRegularFile.InodeNumber]; ok { if requiredInode == requiredRegularFile.InodeNumber { // fmt.Printf("Different links: %s...\n", debugFilename) // HACK } } else { state.subInodeToRequiredInode[subRegularFile.InodeNumber] = requiredRegularFile.InodeNumber } sameMetadata := filesystem.CompareRegularInodesMetadata( subRegularFile.Inode(), requiredRegularFile.Inode(), os.Stdout) sameData := filesystem.CompareRegularInodesData(subRegularFile.Inode(), requiredRegularFile.Inode(), os.Stdout) if sameMetadata && sameData { return } fmt.Printf("Different rfile: %s...\n", debugFilename) // HACK } else { fmt.Printf("Add rfile: %s...\n", debugFilename) // HACK } // TODO(rgooch): Delete entry and replace. }
func scanRegularFile(file *filesystem.RegularFile, fileSystem *FileSystem, parentName string) error { myPathName := path.Join(parentName, file.Name) f, err := os.Open(path.Join(fileSystem.rootDirectoryName, myPathName)) if err != nil { return err } reader := fileSystem.configuration.FsScanContext.NewReader(f) hash := sha512.New() io.Copy(hash, reader) f.Close() copy(file.Inode().Hash[:], hash.Sum(nil)) return nil }