From 590df86561252ca6f83777bb4004daa46e2555cc Mon Sep 17 00:00:00 2001 From: Phi <34374883+rikmarais@users.noreply.github.com> Date: Wed, 16 Aug 2023 14:27:10 +0200 Subject: [PATCH 1/2] Allow world db migration even if sync errors exist --- assets-sync.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/assets-sync.js b/assets-sync.js index 0a22f77..a1b46e0 100644 --- a/assets-sync.js +++ b/assets-sync.js @@ -164,9 +164,8 @@ // update map await this.updateMapFile(); if (this.status === ForgeAssetSync.SYNC_STATUSES.CANCELLED) return; - if (!synced.length && failed.length) return this.setStatus(ForgeAssetSync.SYNC_STATUSES.FAILED); - else if (synced.length && failed.length) return this.setStatus(ForgeAssetSync.SYNC_STATUSES.WITHERRORS); + // Update Foundry World & Compendiums to use local assets let rewriteErrors = false; if (this.updateFoundryDb) { this.setStatus(ForgeAssetSync.SYNC_STATUSES.DBREWRITE); @@ -175,13 +174,21 @@ if (!success) { rewriteErrors = true; new Dialog({ - title: "World database conversion", - content: migration.errorMessage, + title: "World database conversion", + content: migration.errorMessage, buttons: {ok: {label: "OK"}} }, {width: 700}).render(true); } } - if (rewriteErrors) return this.setStatus(ForgeAssetSync.SYNC_STATUSES.WITHERRORS); + + if (synced.length) { + if (failed.length || rewriteErrors) { + return this.setStatus(ForgeAssetSync.SYNC_STATUSES.WITHERRORS); + } + } else if (failed.length || rewriteErrors) { + return this.setStatus(ForgeAssetSync.SYNC_STATUSES.FAILED); + } + this.setStatus(ForgeAssetSync.SYNC_STATUSES.COMPLETE); } From 91ccec7d922125d9087bf65f0282c16e5605dad5 Mon Sep 17 00:00:00 2001 From: Phi <34374883+rikmarais@users.noreply.github.com> Date: Wed, 16 Aug 2023 14:27:46 +0200 Subject: [PATCH 2/2] Check v11 file types before upload --- assets-sync.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/assets-sync.js b/assets-sync.js index a1b46e0..fdc1ff7 100644 --- a/assets-sync.js +++ b/assets-sync.js @@ -700,6 +700,13 @@ if (!asset.name) throw new Error(`Forge VTT | Asset with URL ${asset.url} has no name and cannot be uploaded.`); if (asset.name.endsWith("/")) throw new Error(`Forge VTT | Asset with URL ${asset.url} appears to be a folder.`); if (!blob) throw new Error(`Forge VTT | No Blob data provided for ${asset.name} and therefore it cannot be uploaded to Foundry.`); + if (isNewerVersion(ForgeVTT.foundryVersion, "11")) { + // v11 now provides a list of uploadable file types. If we're on v11, check that the file is allowed. + const isAllowedType = Object.values(CONST.UPLOADABLE_FILE_EXTENSIONS).includes(blob.type); + if (!isAllowedType) { + throw new Error(`Forge VTT | ${asset.name} is not a Foundry uploadable file type and will not be synced.`); + } + } try { const nameParts = asset.name.split("/");