diff --git a/AssetBundleCacher.cs b/AssetBundleCacher.cs index 421b8cb0..4040ad3f 100644 --- a/AssetBundleCacher.cs +++ b/AssetBundleCacher.cs @@ -83,27 +83,25 @@ namespace VRCX /// /// The ID of the asset bundle. /// The version of the asset bundle. - /// An array containing the file size and lock status of the asset bundle. - public long[] CheckVRChatCache(string id, int version) + /// A Tuple containing the file size, lock status and path of the asset bundle. + public Tuple CheckVRChatCache(string id, int version) { - long FileSize = -1; - long IsLocked = 0; - var FullLocation = GetVRChatCacheFullLocation(id, version); - var FileLocation = Path.Combine(FullLocation, "__data"); - if (File.Exists(FileLocation)) + long fileSize = -1; + var isLocked = false; + var fullLocation = GetVRChatCacheFullLocation(id, version); + var fileLocation = Path.Combine(fullLocation, "__data"); + var cachePath = string.Empty; + if (File.Exists(fileLocation)) { - FileInfo data = new FileInfo(FileLocation); - FileSize = data.Length; + cachePath = fullLocation; + FileInfo data = new FileInfo(fileLocation); + fileSize = data.Length; } - if (File.Exists(Path.Combine(FullLocation, "__lock"))) + if (File.Exists(Path.Combine(fullLocation, "__lock"))) { - IsLocked = 1; + isLocked = true; } - return new long[] - { - FileSize, - IsLocked - }; + return new Tuple(fileSize, isLocked, cachePath); } // old asset bundle cacher downloader method reused for updating, it's not pretty diff --git a/html/src/app.js b/html/src/app.js index d2cd7088..203ff723 100644 --- a/html/src/app.js +++ b/html/src/app.js @@ -11399,7 +11399,7 @@ speechSynthesis.getVoices(); } this.checkVRChatCache(avatar).then((cacheInfo) => { var inCache = false; - if (cacheInfo[0] > 0) { + if (cacheInfo.Item1 > 0) { inCache = true; } this.addEntryPhotonEvent({ @@ -11548,7 +11548,7 @@ speechSynthesis.getVoices(); avatar.description = this.replaceBioSymbols(avatar.description); this.checkVRChatCache(avatar).then((cacheInfo) => { var inCache = false; - if (cacheInfo[0] > 0) { + if (cacheInfo.Item1 > 0) { inCache = true; } var entry = { @@ -16419,10 +16419,10 @@ speechSynthesis.getVoices(); this.currentInstanceWorld.avatarScalingDisabled = args.ref?.tags.includes('feature_avatar_scaling_disabled'); this.checkVRChatCache(args.ref).then((cacheInfo) => { - if (cacheInfo[0] > 0) { + if (cacheInfo.Item1 > 0) { this.currentInstanceWorld.inCache = true; this.currentInstanceWorld.cacheSize = `${( - cacheInfo[0] / 1048576 + cacheInfo.Item1 / 1048576 ).toFixed(2)} MiB`; } }); @@ -16446,10 +16446,10 @@ speechSynthesis.getVoices(); this.currentInstanceWorld.isQuest = isQuest; this.currentInstanceWorld.isIos = isIos; this.checkVRChatCache(args.ref).then((cacheInfo) => { - if (cacheInfo[0] > 0) { + if (cacheInfo.Item1 > 0) { this.currentInstanceWorld.inCache = true; this.currentInstanceWorld.cacheSize = `${( - cacheInfo[0] / 1048576 + cacheInfo.Item1 / 1048576 ).toFixed(2)} MiB`; } }); @@ -17048,6 +17048,7 @@ speechSynthesis.getVoices(); inCache: false, cacheSize: 0, cacheLocked: false, + cachePath: '', lastVisit: '', visitCount: 0, timeSpent: 0, @@ -17774,6 +17775,7 @@ speechSynthesis.getVoices(); inCache: false, cacheSize: 0, cacheLocked: false, + cachePath: '', fileAnalysis: {} }; @@ -17810,6 +17812,7 @@ speechSynthesis.getVoices(); D.inCache = false; D.cacheSize = 0; D.cacheLocked = false; + D.cachePath = ''; D.isQuestFallback = false; D.isFavorite = API.cachedFavoritesByObjectId.has(avatarId); D.isBlocked = API.cachedAvatarModerations.has(avatarId); @@ -21951,15 +21954,16 @@ speechSynthesis.getVoices(); D.inCache = false; D.cacheSize = 0; D.cacheLocked = false; + D.cachePath = ''; this.checkVRChatCache(D.ref).then((cacheInfo) => { - if (cacheInfo[0] > 0) { + if (cacheInfo.Item1 > 0) { D.inCache = true; - D.cacheSize = `${(cacheInfo[0] / 1048576).toFixed(2)} MiB`; - D.cachePath = cacheInfo[2]; - } - if (cacheInfo[1] === 1) { - D.cacheLocked = true; + D.cacheSize = `${(cacheInfo.Item1 / 1048576).toFixed( + 2 + )} MiB`; + D.cachePath = cacheInfo.Item3; } + D.cacheLocked = cacheInfo.Item2; }); } }; @@ -21970,14 +21974,16 @@ speechSynthesis.getVoices(); D.inCache = false; D.cacheSize = 0; D.cacheLocked = false; + D.cachePath = ''; this.checkVRChatCache(D.ref).then((cacheInfo) => { - if (cacheInfo[0] > 0) { + if (cacheInfo.Item1 > 0) { D.inCache = true; - D.cacheSize = `${(cacheInfo[0] / 1048576).toFixed(2)} MiB`; - } - if (cacheInfo[1] === 1) { - D.cacheLocked = true; + D.cacheSize = `${(cacheInfo.Item1 / 1048576).toFixed( + 2 + )} MiB`; + D.cachePath = cacheInfo.Item3; } + D.cacheLocked = cacheInfo.Item2; }); } }; @@ -21985,7 +21991,7 @@ speechSynthesis.getVoices(); // eslint-disable-next-line require-await $app.methods.checkVRChatCache = async function (ref) { if (!ref.unityPackages) { - return [-1, 0]; + return { Item1: -1, Item2: false, Item3: '' }; } var assetUrl = ''; for (var i = ref.unityPackages.length - 1; i > -1; i--) { @@ -22001,14 +22007,10 @@ speechSynthesis.getVoices(); var id = extractFileId(assetUrl); var version = parseInt(extractFileVersion(assetUrl), 10); if (!id || !version) { - return [-1, 0]; + return { Item1: -1, Item2: false, Item3: '' }; } - - let cacheData = await AssetBundleCacher.CheckVRChatCache(id, version); - let fullPath = await AssetBundleCacher.GetVRChatCacheFullLocation(id, version); - cacheData.push(fullPath); - - return cacheData; + + return AssetBundleCacher.CheckVRChatCache(id, version); }; API.getBundles = function (fileId) { @@ -22312,7 +22314,7 @@ speechSynthesis.getVoices(); fileVersion ); var inCache = false; - if (cacheInfo[0] > 0) { + if (cacheInfo.Item1 > 0) { inCache = true; } console.log(`InCache: ${inCache}`); diff --git a/html/src/index.pug b/html/src/index.pug index 5fb72a36..7cf5be65 100644 --- a/html/src/index.pug +++ b/html/src/index.pug @@ -572,7 +572,7 @@ html el-tag.x-tag-platform-ios(v-if="worldDialog.isIos" type="info" effect="plain" size="mini" style="margin-right:5px;margin-top:5px") iOS el-tag(v-if="worldDialog.avatarScalingDisabled" type="warning" effect="plain" size="mini" style="margin-right:5px;margin-top:5px") {{ $t('dialog.world.tags.avatar_scaling_disabled') }} el-tag(type="info" effect="plain" size="mini" v-text="worldDialog.fileSize" style="margin-right:5px;margin-top:5px") - el-tag(v-if="worldDialog.inCache" type="info" effect="plain" size="mini" style="margin-right:5px;margin-top:5px" @click="openFolderGeneric(worldDialog.cachePath)") + el-tag.x-link(v-if="worldDialog.inCache" type="info" effect="plain" size="mini" style="margin-right:5px;margin-top:5px" @click="openFolderGeneric(worldDialog.cachePath)") span(v-text="worldDialog.cacheSize") | {{ $t('dialog.world.tags.cache')}} div(style="margin-top:5px") @@ -747,7 +747,7 @@ html el-tag(v-else type="danger" effect="plain" size="mini" style="margin-right:5px") {{ $t('dialog.avatar.tags.private') }} el-tag(v-if="avatarDialog.isQuestFallback" type="info" effect="plain" size="mini" style="margin-right:5px") {{ $t('dialog.avatar.tags.fallback') }} el-tag(v-if="avatarDialog.fileSize" type="info" effect="plain" size="mini" v-text="avatarDialog.fileSize" style="margin-right:5px") - el-tag(v-if="avatarDialog.inCache" type="info" effect="plain" size="mini") + el-tag.x-link(v-if="avatarDialog.inCache" type="info" effect="plain" size="mini" @click="openFolderGeneric(avatarDialog.cachePath)") span(v-text="avatarDialog.cacheSize") | {{ $t('dialog.avatar.tags.cache') }} div(style="margin-top:5px")