(ownerInode msgs.InodeId, filename string)
| 45 | } |
| 46 | |
| 47 | func (r *resolver) Resolve(ownerInode msgs.InodeId, filename string) (string, error) { |
| 48 | filepath := filename |
| 49 | currentDir := ownerInode |
| 50 | for { |
| 51 | // Get the next owner inode. |
| 52 | statReq := msgs.StatDirectoryReq{ |
| 53 | Id: currentDir, |
| 54 | } |
| 55 | statResp := msgs.StatDirectoryResp{} |
| 56 | if err := r.ternClient.ShardRequest(r.logger, currentDir.Shard(), &statReq, &statResp); err != nil { |
| 57 | return "", fmt.Errorf("StatDirectoryReq to shard %v for inode %v failed: %w", currentDir.Shard(), currentDir, err) |
| 58 | } |
| 59 | owner := statResp.Owner |
| 60 | // If we're at the top level, then we're done. |
| 61 | if currentDir == msgs.ROOT_DIR_INODE_ID { |
| 62 | return path.Join("/", filepath), nil |
| 63 | } |
| 64 | // If we've found a null inode ID, then we won't be able to chase things any further. |
| 65 | if owner == msgs.NULL_INODE_ID { |
| 66 | return filepath, nil |
| 67 | } |
| 68 | // Get the name of the next node locally if possible. |
| 69 | if dirName, exists := r.getDirName(currentDir); exists { |
| 70 | filepath = path.Join(dirName, filepath) |
| 71 | currentDir = owner |
| 72 | continue |
| 73 | } |
| 74 | dirName, err := r.getNameFromShard(owner, currentDir) |
| 75 | if err != nil { |
| 76 | return "", fmt.Errorf("failed to lookup directory name from shard: %w", err) |
| 77 | } |
| 78 | r.setDirName(currentDir, dirName) |
| 79 | filepath = path.Join(dirName, filepath) |
| 80 | currentDir = owner |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | func (r *resolver) ResolveFilePaths(input io.Reader, output io.Writer) { |
| 85 | reader := csv.NewReader(input) |
no test coverage detected