Skip to content

Commit 2944b76

Browse files
committed
internxt: add support for dir renaming
1 parent f0cc2b8 commit 2944b76

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

backend/internxt/internxt.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,33 @@ func (f *Fs) CreateDir(ctx context.Context, pathID, leaf string) (string, error)
274274
return resp.UUID, nil
275275
}
276276

277+
// DirMove moves a directory src to dst
278+
func (f *Fs) DirMove(ctx context.Context, src fs.Fs, srcPath, dstPath string) error {
279+
if f != src {
280+
return fs.ErrorCantDirMove
281+
}
282+
283+
srcID, err := f.dirCache.FindDir(ctx, srcPath, false)
284+
if err != nil {
285+
return fs.ErrorDirNotFound
286+
}
287+
288+
dstName := filepath.Base(dstPath)
289+
290+
err = folders.RenameFolder(f.cfg, srcID, f.opt.Encoding.FromStandardName(dstName))
291+
if err != nil {
292+
return fmt.Errorf("rename failed: %w", err)
293+
}
294+
295+
// Invalidate affected caches
296+
f.dirCache.FlushDir(filepath.Dir(srcPath))
297+
f.dirCache.FlushDir(filepath.Dir(dstPath))
298+
f.dirCache.FlushDir(srcPath)
299+
f.dirCache.FlushDir(dstPath)
300+
301+
return nil
302+
}
303+
277304
// List lists a directory
278305
func (f *Fs) List(ctx context.Context, dir string) (fs.DirEntries, error) {
279306
dirID, err := f.dirCache.FindDir(ctx, dir, false)

0 commit comments

Comments
 (0)