Fix file move duplicate incrementing and same folder move bugs, fix tooltip wrap and add hover delay
All checks were successful
Automated Container Build / build-and-push (push) Successful in 59s

This commit is contained in:
Elijah 2026-05-23 08:19:42 -07:00
parent e1f009f273
commit ffea6afeb0
2 changed files with 9 additions and 0 deletions

View file

@ -403,6 +403,10 @@ func (h *FSHandler) Move(c *fiber.Ctx) error {
return c.Status(fiber.StatusForbidden).JSON(fiber.Map{"error": err.Error()}) return c.Status(fiber.StatusForbidden).JSON(fiber.Map{"error": err.Error()})
} }
if srcFull == dstFull || filepath.Dir(srcFull) == dstFull {
return c.JSON(fiber.Map{"message": "moved successfully"})
}
// If destination is a directory, move into it // If destination is a directory, move into it
if info, err := os.Stat(dstFull); err == nil && info.IsDir() { if info, err := os.Stat(dstFull); err == nil && info.IsDir() {
uniqueName := GetUniquePath(dstFull, filepath.Base(srcFull)) uniqueName := GetUniquePath(dstFull, filepath.Base(srcFull))

View file

@ -4,8 +4,11 @@ import (
"fmt" "fmt"
"os" "os"
"path/filepath" "path/filepath"
"regexp"
) )
var numberSuffixRegex = regexp.MustCompile(` \(\d+\)$`)
// GetUniquePath checks if a file or folder exists at the given baseDir with the given name. // GetUniquePath checks if a file or folder exists at the given baseDir with the given name.
// If it does, it systematically appends " (1)", " (2)", etc., until it finds an available name. // If it does, it systematically appends " (1)", " (2)", etc., until it finds an available name.
// It returns the unique filename. // It returns the unique filename.
@ -18,6 +21,8 @@ func GetUniquePath(baseDir, name string) string {
return name return name
} }
base = numberSuffixRegex.ReplaceAllString(base, "")
for i := 1; ; i++ { for i := 1; ; i++ {
newName := fmt.Sprintf("%s (%d)%s", base, i, ext) newName := fmt.Sprintf("%s (%d)%s", base, i, ext)
finalPath = filepath.Join(baseDir, newName) finalPath = filepath.Join(baseDir, newName)