Skip to content

Commit

Permalink
Fixing ALC hints for plagiarism source download.
Browse files Browse the repository at this point in the history
  • Loading branch information
krulis-martin committed Oct 19, 2023
1 parent 5971082 commit b8f6165
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ class PlagiarismCodeBox extends Component {
download(
selectedPlagiarismFile.solutionFile.id,
selectedPlagiarismFile.fileEntry || null,
selectedPlagiarismFile.solutionFile.name,
solutionId
);
}}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/SolutionPlagiarisms/SolutionPlagiarisms.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ export default withRouter(
},
(dispatch, { params }) => ({
loadAsync: () => SolutionPlagiarisms.loadAsync(params, dispatch),
download: (id, entry = null, solutionId = null) => dispatch(download(id, entry, solutionId)),
download: (...args) => dispatch(download(...args)),
addComment: comment => dispatch(addComment(params.solutionId, comment)),
updateComment: comment => dispatch(updateComment(params.solutionId, comment)),
removeComment: id => dispatch(removeComment(params.solutionId, id)),
Expand Down
9 changes: 6 additions & 3 deletions src/redux/modules/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,16 @@ export const fetchFileIfNeeded = actions.fetchOneIfNeeded;
*
* @param {string} fileId
* @param {string|null} entry ZIP archive path (works only for zip uploaded files)
* @param {string|null} saveAs if present, the file will be saved under given name (no need to fetch metadata)
* @param {string|null} similarSolutionId ACL hint if plagiarism source is to be downloaded
* (ID of a solution which is similar with downloaded file)
*/
export const download = (fileId, entry = null, similarSolutionId = null) =>
export const download = (fileId, entry = null, saveAs = null, similarSolutionId = null) =>
downloadHelper({
endpoint: `/uploaded-files/${fileId}/download?` + urlQueryString({ entry, similarSolutionId }),
fetch: entry ? null : fetchFileIfNeeded,
fetch: entry || saveAs ? null : fetchFileIfNeeded,
actionType: actionTypes.DOWNLOAD,
fileNameSelector: entry ? null : (id, state) => getJsData(getFile(id)(state)).name,
fileNameSelector: saveAs ? () => saveAs : entry ? null : (id, state) => getJsData(getFile(id)(state)).name,
contentType: 'application/octet-stream',
})(fileId, entry && entry.split('/').pop());

Expand Down

0 comments on commit b8f6165

Please sign in to comment.