MCPcopy
hub / github.com/rclone/rclone / NewFs

Function NewFs

backend/http/http.go:310–346  ·  view source on GitHub ↗

NewFs creates a new Fs object from the name and root. It connects to the host specified in the config file.

(ctx context.Context, name, root string, m configmap.Mapper)

Source from the content-addressed store, hash-verified

308// NewFs creates a new Fs object from the name and root. It connects to
309// the host specified in the config file.
310func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, error) {
311 // Parse config into Options struct
312 opt := new(Options)
313 err := configstruct.Set(m, opt)
314 if err != nil {
315 return nil, err
316 }
317
318 ci := fs.GetConfig(ctx)
319 f := &Fs{
320 name: name,
321 root: root,
322 opt: *opt,
323 ci: ci,
324 }
325 f.features = (&fs.Features{
326 ReadMetadata: true,
327 CanHaveEmptyDirectories: true,
328 }).Fill(ctx, f)
329
330 // Make the http connection
331 isFile, err := f.httpConnection(ctx, opt)
332 if err != nil {
333 return nil, err
334 }
335
336 if isFile {
337 // return an error with an fs which points to the parent
338 return f, fs.ErrorIsFile
339 }
340
341 if !strings.HasSuffix(f.endpointURL, "/") {
342 return nil, errors.New("internal error: url doesn't end with /")
343 }
344
345 return f, nil
346}
347
348// Name returns the configured name of the file system
349func (f *Fs) Name() string {

Callers 5

prepareFunction · 0.70
TestOpenFunction · 0.70
TestIsAFileRootFunction · 0.70
TestIsAFileSubDirFunction · 0.70
TestFsNoSlashRootsFunction · 0.70

Calls 4

httpConnectionMethod · 0.95
SetFunction · 0.92
GetConfigFunction · 0.92
FillMethod · 0.80

Tested by 5

prepareFunction · 0.56
TestOpenFunction · 0.56
TestIsAFileRootFunction · 0.56
TestIsAFileSubDirFunction · 0.56
TestFsNoSlashRootsFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…