MCPcopy
hub / github.com/rclone/rclone / Mkdir

Method Mkdir

backend/cache/cache.go:1153–1180  ·  view source on GitHub ↗

Mkdir makes the directory (container, bucket)

(ctx context.Context, dir string)

Source from the content-addressed store, hash-verified

1151
1152// Mkdir makes the directory (container, bucket)
1153func (f *Fs) Mkdir(ctx context.Context, dir string) error {
1154 fs.Debugf(f, "mkdir '%s'", dir)
1155 err := f.Fs.Mkdir(ctx, dir)
1156 if err != nil {
1157 return err
1158 }
1159 fs.Debugf(dir, "mkdir: created dir in source fs")
1160
1161 cd := NewDirectory(f, cleanPath(dir))
1162 err = f.cache.AddDir(cd)
1163 if err != nil {
1164 fs.Errorf(dir, "mkdir: add error: %v", err)
1165 } else {
1166 fs.Debugf(cd, "mkdir: added to cache")
1167 }
1168 // expire parent of new dir
1169 parentCd := NewDirectory(f, cleanPath(path.Dir(dir)))
1170 err = f.cache.ExpireDir(parentCd)
1171 if err != nil {
1172 fs.Errorf(parentCd, "mkdir: cache expire error: %v", err)
1173 } else {
1174 fs.Infof(parentCd, "mkdir: cache expired")
1175 }
1176 // advertise to ChangeNotify if wrapped doesn't do that
1177 f.notifyChangeUpstreamIfNeeded(parentCd.Remote(), fs.EntryDirectory)
1178
1179 return nil
1180}
1181
1182// Rmdir removes the directory (container, bucket) if empty
1183func (f *Fs) Rmdir(ctx context.Context, dir string) error {

Callers 1

newCacheFsMethod · 0.95

Calls 11

RemoteMethod · 0.95
DebugfFunction · 0.92
ErrorfFunction · 0.92
InfofFunction · 0.92
cleanPathFunction · 0.85
DirMethod · 0.80
ExpireDirMethod · 0.80
NewDirectoryFunction · 0.70
MkdirMethod · 0.65
AddDirMethod · 0.45

Tested by 1

newCacheFsMethod · 0.76