fix: resolve upload delay and refine trash functionality
All checks were successful
Automated Container Build / build-and-push (push) Successful in 1m22s

This commit is contained in:
Elijah 2026-05-23 14:11:23 -07:00
parent 45989ef97d
commit db946461d7
3 changed files with 49 additions and 21 deletions

View file

@ -534,6 +534,19 @@ func (h *FSHandler) Delete(c *fiber.Ctx) error {
return c.Status(fiber.StatusNotFound).JSON(fiber.Map{"error": "file not found"})
}
// Check if permanent
isPermanent := c.Query("permanent") == "true"
if isPermanent {
if err := os.RemoveAll(resolvedPath); err != nil {
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": "failed to permanently delete"})
}
cleanPath := filepath.ToSlash(relativePath)
h.DB.Exec(`DELETE FROM files WHERE path = ? OR path LIKE ?`, cleanPath, cleanPath+"/%")
h.DB.AddAuditLog("permanently_deleted", cleanPath, c.IP())
return c.JSON(fiber.Map{"message": "permanently deleted"})
}
// Soft-delete: move to .trash directory
trashPath := filepath.Join(h.Config.TrashDir, relativePath)
if err := os.MkdirAll(filepath.Dir(trashPath), 0755); err != nil {