Skip to content

Commit

Permalink
add longer timeout on directory, add toast for zipping folders
Browse files Browse the repository at this point in the history
  • Loading branch information
seliayeu committed Jun 26, 2023
1 parent 67b77f2 commit 9071734
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/components/FileViewer/FileViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,12 @@ export default function FileViewer() {
if (!tickedFiles) return;

for (const file of tickedFiles) {
downloadInstanceFile(instance.uuid, file);
const timeout = file?.file_type == 'Directory' ? 60000 : 5000;
if (file.file_type === 'Directory') {
toast.info('Zipping directory for download...');
}

downloadInstanceFile(instance.uuid, file, timeout);
tickFile(file, false);
}
};
Expand Down
8 changes: 5 additions & 3 deletions src/utils/apis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,21 @@ export const deleteInstanceDirectory = async (

export const requestInstanceFileUrl = async (
uuid: string,
file: ClientFile
file: ClientFile,
timeout = 5000,
): Promise<string> => {
const tokenResponse = await axiosWrapper<string>({
method: 'get',
url: `/instance/${uuid}/fs/${Base64.encode(file.path, true)}/url`,
timeout: timeout,
});
return axios.defaults.baseURL + `/file/${tokenResponse}`;
};

export const downloadInstanceFile = async (uuid: string, file: ClientFile) => {
export const downloadInstanceFile = async (uuid: string, file: ClientFile, timeout = 5000) => {
// TODO handle errors

window.open(await requestInstanceFileUrl(uuid, file), '_blank');
window.open(await requestInstanceFileUrl(uuid, file, timeout), '_blank');
};

export const uploadInstanceFiles = async (
Expand Down

0 comments on commit 9071734

Please sign in to comment.