Get implements Storage.Get
(ctx context.Context, key string, source string, update bool)
| 41 | |
| 42 | // Get implements Storage.Get |
| 43 | func (s *FolderStorage) Get(ctx context.Context, key string, source string, update bool) error { |
| 44 | dir := s.dir(key) |
| 45 | if !update { |
| 46 | if _, err := os.Stat(dir); err == nil { |
| 47 | // If the directory already exists, then we're done since |
| 48 | // we're not updating. |
| 49 | return nil |
| 50 | } else if !os.IsNotExist(err) { |
| 51 | // If the error we got wasn't a file-not-exist error, then |
| 52 | // something went wrong and we should report it. |
| 53 | return fmt.Errorf("Error reading module directory: %s", err) |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | // Get the source. This always forces an update. |
| 58 | _, err := Get(ctx, dir, source) |
| 59 | return err |
| 60 | } |
| 61 | |
| 62 | // dir returns the directory name internally that we'll use to map to |
| 63 | // internally. |