(prefix string)
| 300 | } |
| 301 | |
| 302 | func (g *PublishedStorage) internalFilelist(prefix string) ([]string, []string, error) { |
| 303 | paths := make([]string, 0, 1024) |
| 304 | md5s := make([]string, 0, 1024) |
| 305 | |
| 306 | fullPrefix := filepath.Join(g.prefix, prefix) |
| 307 | if fullPrefix != "" { |
| 308 | fullPrefix += "/" |
| 309 | } |
| 310 | |
| 311 | it := g.bucket.Objects(context.TODO(), &storage.Query{Prefix: fullPrefix}) |
| 312 | for { |
| 313 | attrs, err := it.Next() |
| 314 | if err == iterator.Done { |
| 315 | break |
| 316 | } |
| 317 | if err != nil { |
| 318 | return nil, nil, errors.WithMessagef(err, "error listing under prefix %s in %s", fullPrefix, g) |
| 319 | } |
| 320 | |
| 321 | path := attrs.Name |
| 322 | if fullPrefix != "" { |
| 323 | path = strings.TrimPrefix(path, fullPrefix) |
| 324 | } |
| 325 | paths = append(paths, path) |
| 326 | |
| 327 | if attrs.Metadata != nil { |
| 328 | if md5, ok := attrs.Metadata["Md5"]; ok && md5 != "" { |
| 329 | md5s = append(md5s, strings.ToLower(md5)) |
| 330 | continue |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | md5s = append(md5s, strings.ToLower(hex.EncodeToString(attrs.MD5))) |
| 335 | } |
| 336 | |
| 337 | return paths, md5s, nil |
| 338 | } |
| 339 | |
| 340 | // RenameFile renames (moves) file. |
| 341 | func (g *PublishedStorage) RenameFile(oldName, newName string) error { |
no outgoing calls
no test coverage detected