Cleanup temporary writers upon errors during putObject(), all metadata() write operations

This commit is contained in:
Harshavardhana
2015-07-10 14:04:37 -07:00
parent 6860b310c9
commit 29838bb851
5 changed files with 49 additions and 19 deletions
+9
View File
@@ -24,6 +24,8 @@ import (
"sort"
"strings"
"unicode/utf8"
"github.com/minio/minio/pkg/utils/atomic"
)
// IsValidBucket - verify bucket name in accordance with
@@ -163,3 +165,10 @@ func SortU(objects []string) []string {
sort.Strings(results)
return results
}
// CleanupWritersOnError purge writers on error
func CleanupWritersOnError(writers []io.WriteCloser) {
for _, writer := range writers {
writer.(*atomic.File).CloseAndPurge()
}
}