diff --git a/webui/workspaces.php b/webui/workspaces.php index f854a39..e8ae479 100644 --- a/webui/workspaces.php +++ b/webui/workspaces.php @@ -97,13 +97,37 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { if ($action === 'delete') { if (is_dir($wsPath)) { + // Debug info + $currentUser = trim(shell_exec('whoami')); + // Delete directory recursively using sudo - exec("sudo rm -rf " . escapeshellarg($wsPath)); + $cmd = "sudo rm -rf " . escapeshellarg($wsPath) . " 2>&1"; + exec($cmd, $output, $returnVar); if (!file_exists($wsPath)) { - echo json_encode(['success' => true, 'message' => 'Workspace deleted']); + echo json_encode([ + 'success' => true, + 'message' => 'Workspace deleted', + 'debug' => [ + 'user' => $currentUser, + 'cmd' => $cmd, + 'output' => implode("\n", $output), + 'return' => $returnVar + ] + ]); } else { - echo json_encode(['success' => false, 'error' => 'Failed to delete workspace. Check permissions.']); + echo json_encode([ + 'success' => false, + 'error' => 'Failed to delete workspace.', + 'debug' => [ + 'user' => $currentUser, + 'cmd' => $cmd, + 'output' => implode("\n", $output), + 'return' => $returnVar, + 'permissions' => substr(sprintf('%o', fileperms($wsPath)), -4), + 'owner' => posix_getpwuid(fileowner($wsPath))['name'] + ] + ]); } } else { echo json_encode(['success' => false, 'error' => 'Workspace not found']);