-// fromUUID is empty) and applying the specified splice operations.
-func (conn *Conn) applySplices(ctx context.Context, fromUUID string, attrs map[string]interface{}) error {
- var splices map[string]string
-
- // Validate the incoming attrs, and return early if the
- // request doesn't ask for any splices.
- if sp, ok := attrs["splices"]; !ok {
- return nil
- } else {
- switch sp := sp.(type) {
- default:
- return httpserver.Errorf(http.StatusBadRequest, "invalid type %T for splices parameter", sp)
- case nil:
- return nil
- case map[string]string:
- splices = sp
- case map[string]interface{}:
- splices = make(map[string]string, len(sp))
- for dst, src := range sp {
- if src, ok := src.(string); ok {
- splices[dst] = src
- } else {
- return httpserver.Errorf(http.StatusBadRequest, "invalid source type for splice target %q: %v", dst, src)
- }
- }
- }
- if len(splices) == 0 {
- return nil
- } else if mtxt, ok := attrs["manifest_text"].(string); ok && len(mtxt) > 0 {
- return httpserver.Errorf(http.StatusBadRequest, "ambiguous request: both 'splices' and 'manifest_text' values provided")
- }
+// fromUUID is empty) and applying the specified file/directory
+// replacements.
+//
+// Return value is the (possibly modified) attrs map.
+func (conn *Conn) applyReplaceFilesOption(ctx context.Context, fromUUID string, attrs map[string]interface{}, replaceFiles map[string]string) (map[string]interface{}, error) {
+ if len(replaceFiles) == 0 {
+ return attrs, nil
+ } else if mtxt, ok := attrs["manifest_text"].(string); ok && len(mtxt) > 0 {
+ return nil, httpserver.Errorf(http.StatusBadRequest, "ambiguous request: both 'replace_files' and attrs['manifest_text'] values provided")