Remove implements the server
(stream remote.Upstream_RemoveServer)
| 107 | |
| 108 | // Remove implements the server |
| 109 | func (u *Upstream) Remove(stream remote.Upstream_RemoveServer) error { |
| 110 | // Receive file |
| 111 | for { |
| 112 | paths, err := stream.Recv() |
| 113 | if paths != nil { |
| 114 | for _, path := range paths.Paths { |
| 115 | // Just remove everything inside and ignore any errors |
| 116 | absolutePath := filepath.Join(u.options.UploadPath, path) |
| 117 | |
| 118 | // Stat the path |
| 119 | stat, err := os.Stat(absolutePath) |
| 120 | if err != nil { |
| 121 | continue |
| 122 | } |
| 123 | |
| 124 | if stat.IsDir() { |
| 125 | _ = u.removeRecursive(absolutePath) |
| 126 | } else { |
| 127 | _ = os.Remove(absolutePath) |
| 128 | } |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | if err == io.EOF { |
| 133 | return stream.SendAndClose(&remote.Empty{}) |
| 134 | } |
| 135 | if err != nil { |
| 136 | return err |
| 137 | } |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | func (u *Upstream) Checksums(ctx context.Context, paths *remote.TouchPaths) (*remote.PathsChecksum, error) { |
| 142 | if paths != nil { |
nothing calls this directly
no test coverage detected