feat: complete remediation phase 3
Some checks failed
Automated Container Build / build-and-push (push) Failing after 15s
Some checks failed
Automated Container Build / build-and-push (push) Failing after 15s
This commit is contained in:
parent
0221e277a6
commit
6772ba8c43
10 changed files with 63 additions and 20 deletions
|
|
@ -554,7 +554,7 @@ func (h *FSHandler) Delete(c *fiber.Ctx) error {
|
|||
isPermanent := c.Query("permanent") == "true"
|
||||
if isPermanent {
|
||||
// Ensure we don't delete the root
|
||||
if resolvedPath == c.Locals("resolvedPath").(string) && relativePath == "." {
|
||||
if resolvedPath == h.Config.StorageDir && relativePath == "." {
|
||||
return c.Status(fiber.StatusForbidden).JSON(fiber.Map{"error": "cannot permanently delete root"})
|
||||
}
|
||||
|
||||
|
|
@ -592,8 +592,14 @@ func (h *FSHandler) Delete(c *fiber.Ctx) error {
|
|||
|
||||
if err := os.Rename(resolvedPath, trashPath); err != nil {
|
||||
fmt.Printf("Rename error %s -> %s: %v. Attempting copy & delete fallback...\n", resolvedPath, trashPath, err)
|
||||
if err := copyFile(resolvedPath, trashPath); err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": "failed to move to trash"})
|
||||
if isDir == 1 {
|
||||
if err := copyDir(resolvedPath, trashPath); err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": "failed to move directory to trash"})
|
||||
}
|
||||
} else {
|
||||
if err := copyFile(resolvedPath, trashPath); err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": "failed to move file to trash"})
|
||||
}
|
||||
}
|
||||
safeRemovePath(h.Config.StorageDir, resolvedPath)
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue