Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
SahilAggarwal2004 committed Jun 3, 2024
1 parent a8d05cf commit e03fd5a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/components/FileDownload.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function FileDownload({ fileIdFromUrl = false }) {
const { setDownloadFiles, fetchApp, setModal } = useFileContext();
const fileRef = useRef();
const password = useRef();
const [unzipFile, setUnzip] = useStorage("unzip", true);
const [unzipFile, setUnzip] = useStorage("unzip", false);
const [progress, setProgress] = useState(-1);
const isDownloaded = progress === 100;
const isDownloading = progress >= 0 && !isDownloaded;
Expand Down Expand Up @@ -44,6 +44,7 @@ export default function FileDownload({ fileIdFromUrl = false }) {

async function downloadFile(blob, name) {
try {
setProgress(100);
if (!blob) throw new Error();
try {
if (!unzipFile || !regex.test(name)) throw new Error();
Expand All @@ -59,6 +60,7 @@ export default function FileDownload({ fileIdFromUrl = false }) {
if (server) return;
setDownloadFiles((prev) => prev.filter(({ _id }) => _id !== fileId).concat({ nameList, _id: fileId, createdAt, daysLimit }));
} catch {
setProgress(-1);
toast.error("Couldn't download file(s)");
}
}
Expand Down

0 comments on commit e03fd5a

Please sign in to comment.