MCPcopy Create free account
hub / github.com/OpenListTeam/OpenList / Put

Method Put

drivers/smb/driver.go:181–203  ·  view source on GitHub ↗
(ctx context.Context, dstDir model.Obj, stream model.FileStreamer, up driver.UpdateProgress)

Source from the content-addressed store, hash-verified

179}
180
181func (d *SMB) Put(ctx context.Context, dstDir model.Obj, stream model.FileStreamer, up driver.UpdateProgress) error {
182 if err := d.checkConn(ctx); err != nil {
183 return err
184 }
185 fullPath := filepath.Join(dstDir.GetPath(), stream.GetName())
186 out, err := d.fs.Create(fullPath)
187 if err != nil {
188 d.cleanLastConnTime()
189 return err
190 }
191 d.updateLastConnTime()
192 defer func() {
193 _ = out.Close()
194 if errors.Is(err, context.Canceled) {
195 _ = d.fs.Remove(fullPath)
196 }
197 }()
198 err = utils.CopyWithCtx(ctx, out, driver.NewLimitedUploadStream(ctx, stream), stream.GetSize(), up)
199 if err != nil {
200 return err
201 }
202 return nil
203}
204
205func (d *SMB) GetDetails(ctx context.Context) (*model.StorageDetails, error) {
206 if err := d.checkConn(ctx); err != nil {

Callers

nothing calls this directly

Calls 11

checkConnMethod · 0.95
cleanLastConnTimeMethod · 0.95
updateLastConnTimeMethod · 0.95
CopyWithCtxFunction · 0.92
NewLimitedUploadStreamFunction · 0.92
GetPathMethod · 0.65
GetNameMethod · 0.65
CreateMethod · 0.65
CloseMethod · 0.65
RemoveMethod · 0.65
GetSizeMethod · 0.65

Tested by

no test coverage detected