Skip to content

Commit

Permalink
Fixed issues
Browse files Browse the repository at this point in the history
  • Loading branch information
justinnas committed Sep 9, 2024
1 parent 94260ba commit 3c097e7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions app/back-end/src/routes/workspace_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -1197,43 +1197,43 @@ def export_file(relative_path):
)

response = send_file(file_path, as_attachment=True)

return response

except FileNotFoundError as e:
logger.error("FileNotFoundError: %s while accessing %s", e, user_workspace_dir)
logger.error("FileNotFoundError: %s while exporting %s", e, user_workspace_dir)
# Emit a feedback to the user's console
socketio_emit_to_user_session(
CONSOLE_FEEDBACK_EVENT,
{
"type": "errr",
"message": f"FileNotFoundError: {e} while accessing {user_workspace_dir}",
"message": f"FileNotFoundError: {e} while exporting {user_workspace_dir}",
},
uuid,
sid,
)
return jsonify({"error": "Requested file not found"}), 404
except PermissionError as e:
logger.error("PermissionError: %s while accessing %s", e, user_workspace_dir)
logger.error("PermissionError: %s while exporting %s", e, user_workspace_dir)
# Emit a feedback to the user's console
socketio_emit_to_user_session(
CONSOLE_FEEDBACK_EVENT,
{
"type": "errr",
"message": f"PermissionError: {e} while accessing {user_workspace_dir}",
"message": f"PermissionError: {e} while exporting {user_workspace_dir}",
},
uuid,
sid,
)
return jsonify({"error": "Permission denied"}), 403
except UnexpectedError as e:
logger.error("UnexpectedError: %s while accessing %s", e.message, user_workspace_dir)
logger.error("UnexpectedError: %s while exporting %s", e.message, user_workspace_dir)
# Emit a feedback to the user's console
socketio_emit_to_user_session(
CONSOLE_FEEDBACK_EVENT,
{
"type": "errr",
"message": f"UnexpectedError: {e.message} while accessing {user_workspace_dir}",
"message": f"UnexpectedError: {e.message} while exporting {user_workspace_dir}",
},
uuid,
sid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { FileTreeItemContextMenuActions, FileTreeViewItemProps, FileTypes } from
import { axios } from '@/lib';
import { Endpoints } from '@/types';
import { Divider, Menu, MenuItem } from '@mui/material';
import { useState } from 'react';
import { useCallback, useState } from 'react';

export interface FileTreeItemContextMenuProps {
item: FileTreeViewItemProps;
Expand Down Expand Up @@ -157,7 +157,7 @@ export const FileTreeItemContextMenu: React.FC<FileTreeItemContextMenuProps> = (
filesHistoryStateUpdate(undefined, { id: item.id, label: item.label, type: item.fileType || FileTypes.FILE });
};

const handleExport = async () => {
const handleExport = useCallback(async () => {
try {
const response = await axios.get(`${Endpoints.WORKSPACE_EXPORT}/${item.id}`, {
responseType: 'blob',
Expand All @@ -179,7 +179,7 @@ export const FileTreeItemContextMenu: React.FC<FileTreeItemContextMenuProps> = (
} catch (error) {
console.error('Error exporting file:', error);
}
};
}, [item.id]);

return (
<>
Expand Down

0 comments on commit 3c097e7

Please sign in to comment.