diff --git a/app.py b/app.py index fe50e73..638de68 100644 --- a/app.py +++ b/app.py @@ -285,20 +285,20 @@ async def rename_directory(paths: dict[str, str], verbose: Optional[bool] = Quer failed_paths = {} for old_name, new_name in paths.items(): - old_directory = secure_path(old_name) - new_directory = secure_path(new_name) + old_path = secure_path(old_name) + new_path = secure_path(new_name) - if not old_directory.exists() or not old_directory.is_dir(): + if not old_path.exists() or not old_path.exists(): #raise HTTPException(status_code=404, detail="Directory not found") failed_paths[old_name] = new_name continue - if new_directory.exists(): + if new_path.exists(): failed_paths[old_name] = new_name continue try: - old_directory.rename(new_directory) + old_path.rename(new_path) except Exception as e: #raise HTTPException(status_code=500, detail=str(e)) failed_paths[old_name] = new_name @@ -434,4 +434,4 @@ def custom_http_exception_handler(request: Request, exc: HTTPException): return JSONResponse( status_code=exc.status_code, content={"message": exc.detail} # Change "detail" to "message" - ) \ No newline at end of file + ) diff --git a/client/src/components/home/ContextMenu.tsx b/client/src/components/home/ContextMenu.tsx index 5350cc3..c01e50b 100644 --- a/client/src/components/home/ContextMenu.tsx +++ b/client/src/components/home/ContextMenu.tsx @@ -2,11 +2,9 @@ import React, { useRef, useEffect, useState } from "react"; import ConfirmationModal from "./ConfirmationModal"; import Notification from "./Notification"; - interface ContextMenuProps { fileName: string; open: string; - onDelete: string; rename: string; mime_type: string; @@ -24,7 +22,6 @@ const ContextMenu: React.FC = ({ isOpen, toggleMenu, refreshData, - }) => { const menuRef = useRef(null); const buttonRef = useRef(null); @@ -126,7 +123,7 @@ const ContextMenu: React.FC = ({ }; const handleRename = async () => { - const newName = prompt("Enter new file name:"); + const newName = prompt("Enter new file name:", fileName); if (newName) { try { const response = await fetch(`http://127.0.0.1:8000/api/file`, { @@ -198,24 +195,26 @@ const ContextMenu: React.FC = ({