Skip to content

Commit

Permalink
log asset status in console
Browse files Browse the repository at this point in the history
  • Loading branch information
dromzeh committed Jun 18, 2024
1 parent 0fc3c88 commit 0dcd2bd
Showing 1 changed file with 25 additions and 15 deletions.
40 changes: 25 additions & 15 deletions src/components/asset/download-indicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,26 +209,36 @@ function ShowMassDownloadProgress() {
return <CircleMinus size={16} />;
};

const validateAssetPath = (path: string): boolean => {
return /^https:\/\/cdn\.wanderer\.moe\/[a-z0-9-]+\/[a-z0-9-]+\/[a-z0-9-]+\.png$/i.test(
path,
);
};
// const validateAssetPath = (path: string): boolean => {
// return /^https:\/\/cdn\.wanderer\.moe\/[a-z0-9-]+\/[a-z0-9-]+\/[a-z0-9-]+\.png$/i.test(
// path,
// );
// };

const fetchAsset = async (asset: Asset, zip: JSZip): Promise<void> => {
const [, , , game, category] = asset.path.split("/");
console.log("[Mass Downloading] Fetching asset", asset.path);
try {
const [, , , game, category] = asset.path.split("/");

if (!validateAssetPath(asset.path)) {
console.error("Invalid asset path:", asset.path);
return;
}
// if (!validateAssetPath(asset.path)) {
// console.error("Invalid asset path:", asset.path);
// return;
// }

const response = await axios.get(asset.path, {
responseType: "arraybuffer",
});
const response = await axios.get(asset.path, {
responseType: "arraybuffer",
});

zip.file(`${game}/${category}/${asset.name}.png`, response.data);
setFetchedAssets((prev) => prev + 1);
zip.file(`${game}/${category}/${asset.name}.png`, response.data);
setFetchedAssets((prev) => prev + 1);
} catch (error) {
console.error(
"[Mass Downloading] Failed to fetch asset",
asset.path,
error,
);
throw error;
}
};

const downloadAndZipAssets = async () => {
Expand Down

0 comments on commit 0dcd2bd

Please sign in to comment.