Drag and drop files between folders

This commit is contained in:
2026-05-22 20:08:09 +02:00
parent a3e4a08281
commit 88eebf6944
5 changed files with 85 additions and 7 deletions
+13
View File
@@ -63,6 +63,19 @@ func DeleteFile(dataDir, userID, relPath string) error {
return os.RemoveAll(p)
}
// MoveFile moves a file or folder to a new path.
func MoveFile(dataDir, userID, fromRel, toRel string) error {
from := safePath(dataDir, userID, fromRel)
to := safePath(dataDir, userID, toRel)
if from == "" || to == "" {
return os.ErrPermission
}
if err := os.MkdirAll(filepath.Dir(to), 0755); err != nil {
return err
}
return os.Rename(from, to)
}
// ListTree returns the file tree for a user.
func ListTree(dataDir, userID string) ([]FileInfo, error) {
root := UserDir(dataDir, userID)