~jameinel/juju-core/api-registry-tracks-type

« back to all changes in this revision

Viewing changes to environs/storage.go

Merged local-sudo-caller into local-provider-bootstrap.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2013 Canonical Ltd.
 
2
// Licensed under the AGPLv3, see LICENCE file for details.
 
3
 
 
4
package environs
 
5
 
 
6
import (
 
7
        "fmt"
 
8
)
 
9
 
 
10
// RemoveAll is a default implementation for StorageWriter.RemoveAll.
 
11
// Providers may have more efficient implementations, or better error handling,
 
12
// or safeguards against races with other users of the same storage medium.
 
13
// But a simple way to implement RemoveAll would be to delegate to here.
 
14
func RemoveAll(stor Storage) error {
 
15
        files, err := stor.List("")
 
16
        if err != nil {
 
17
                return fmt.Errorf("unable to list files for deletion: %v", err)
 
18
        }
 
19
 
 
20
        // Some limited parallellism might be useful in this loop.
 
21
        for _, file := range files {
 
22
                err = stor.Remove(file)
 
23
                if err != nil {
 
24
                        break
 
25
                }
 
26
        }
 
27
        return err
 
28
}