func (t *Fs) put(rid string, d zx.Dir, off int64, dc <-chan []byte, pred string) error { pf, err := t.walk(path.Dir(rid)) if err != nil { return err } pd, err := pf.Stat() if pd["type"] != "d" { return fmt.Errorf("%s: %s", pd["path"], dbg.ErrNotDir) } wpf, ok := pf.(Walker) if !ok { return fmt.Errorf("%s: %s", pd["path"], dbg.ErrPerm) } f, err := wpf.Walk(path.Base(rid)) if err != nil && !dbg.IsNotExist(err) { return err } if err != nil { if err := t.matchDir(rid, nil, pred); err != nil { return err } if !t.NoPermCheck && !pd.CanWrite(t.ai) { return fmt.Errorf("%s: %s", rid, dbg.ErrPerm) } if putf, ok := pf.(Putter); ok { return putf.Put(path.Base(rid), d, off, dc) } return fmt.Errorf("%s: %s", pd["path"], dbg.ErrPerm) } else { d, err := f.Stat() if err != nil { return err } if d["type"] == "d" { return fmt.Errorf("%s: %s", rid, dbg.ErrIsDir) } if err := t.matchDir(rid, d, pred); err != nil { return err } if !t.NoPermCheck && !d.CanWrite(t.ai) { return fmt.Errorf("%s: %s", rid, dbg.ErrPerm) } if putf, ok := f.(Putter); ok { return putf.Put("", d, off, dc) } return fmt.Errorf("%s: %s", d["path"], dbg.ErrPerm) } }