func (sub *Sub) getFileToCopy(myPathName string, hashVal hash.Hash) subproto.FileToCopyToCache { subFS := sub.FileSystem requiredFS := sub.requiredFS inos, ok := subFS.HashToInodesTable()[hashVal] if !ok { panic("No object in cache for: " + myPathName) } file := subproto.FileToCopyToCache{ Name: subFS.InodeToFilenamesTable()[inos[0]][0], Hash: hashVal, } // Try to find an inode where all its links will be deleted and mark one of // the links (filenames) to be hardlinked instead of copied into the cache. for _, iNum := range inos { filenames := subFS.InodeToFilenamesTable()[iNum] for _, filename := range filenames { if _, ok := requiredFS.FilenameToInodeTable()[filename]; ok { filenames = nil break } if sub.filter == nil || sub.filter.Match(filename) { filenames = nil break } } if filenames != nil { file.DoHardlink = true break } } return file }