// Write the opaque metadata blobs (by name). // Each blob in the metadata map is written to a file with the corresponding // name. Likewise, when we read it back (on restart) we populate the map // accordingly. func writeMetadata(ctx context.Context, ds *datastore.Helper, dir string, meta map[string][]byte) error { // XXX this should be done via disklib so this meta follows the disk in // case of motion. if meta != nil && len(meta) != 0 { for name, value := range meta { r := bytes.NewReader(value) pth := path.Join(dir, name) log.Infof("Writing metadata %s", pth) if err := ds.Upload(ctx, r, pth); err != nil { return err } } } else { if _, err := ds.Mkdir(ctx, false, dir); err != nil { return err } } return nil }