mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-19 14:53:50 +02:00
AssetBundleCacher 2
This commit is contained in:
@@ -240,7 +240,7 @@ namespace VRCX
|
|||||||
File.Delete(Path.Combine(VRChatCacheLocation, "Cache-WindowsPlayer", "__info"));
|
File.Delete(Path.Combine(VRChatCacheLocation, "Cache-WindowsPlayer", "__info"));
|
||||||
File.Move(Path.Combine(AssetBundleCacherTemp, "__info"), Path.Combine(VRChatCacheLocation, "Cache-WindowsPlayer", "__info"));
|
File.Move(Path.Combine(AssetBundleCacherTemp, "__info"), Path.Combine(VRChatCacheLocation, "Cache-WindowsPlayer", "__info"));
|
||||||
Directory.Delete(Path.Combine(VRChatCacheLocation, "AssetBundleCacher\\Cache", AssetId), true);
|
Directory.Delete(Path.Combine(VRChatCacheLocation, "AssetBundleCacher\\Cache", AssetId), true);
|
||||||
//File.Delete(Path.Combine(VRChatCacheLocation, "AssetBundleCacher", AssetId));
|
File.Delete(Path.Combine(VRChatCacheLocation, "AssetBundleCacher", AssetId));
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|||||||
166
html/src/app.js
166
html/src/app.js
@@ -3439,6 +3439,13 @@ speechSynthesis.getVoices();
|
|||||||
: '';
|
: '';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var extractFileVersion = (s) => {
|
||||||
|
var match = /(?:\/file_[0-9A-Za-z-]+\/)([0-9]+)/gi.exec(s);
|
||||||
|
return match
|
||||||
|
? match[1]
|
||||||
|
: '';
|
||||||
|
};
|
||||||
|
|
||||||
var buildTreeData = (json) => {
|
var buildTreeData = (json) => {
|
||||||
var node = [];
|
var node = [];
|
||||||
for (var key in json) {
|
for (var key in json) {
|
||||||
@@ -8265,17 +8272,34 @@ speechSynthesis.getVoices();
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
D.ref = ref;
|
D.ref = ref;
|
||||||
|
$app.applyWorldDialogInstances();
|
||||||
if (D.fileSize === 'Loading') {
|
if (D.fileSize === 'Loading') {
|
||||||
var id = extractFileId(ref.assetUrl);
|
var assetUrl = '';
|
||||||
if (id) {
|
for (var i = ref.unityPackages.length - 1; i > -1; i--) {
|
||||||
this.call(`file/${id}`).then(function (json) {
|
var unityPackage = ref.unityPackages[i];
|
||||||
var ctx = json.versions[json.versions.length - 1];
|
if ((unityPackage.platform === 'standalonewindows') &&
|
||||||
D.fileCreatedAt = ctx.created_at;
|
(unityPackage.unitySortNumber <= 20180420000)) {
|
||||||
D.fileSize = `${(ctx.file.sizeInBytes / 1048576).toFixed(2)} MiB`;
|
assetUrl = unityPackage.assetUrl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var fileId = extractFileId(assetUrl);
|
||||||
|
var fileVersion = extractFileVersion(assetUrl);
|
||||||
|
if (fileId) {
|
||||||
|
API.getBundles(fileId).then((args) => {
|
||||||
|
var { versions } = args.json;
|
||||||
|
var ctx = '';
|
||||||
|
for (var i = versions.length - 1; i > -1; i--) {
|
||||||
|
var version = versions[i];
|
||||||
|
if (version.version == fileVersion) {
|
||||||
|
D.fileCreatedAt = version.created_at;
|
||||||
|
D.fileSize = `${(version.file.sizeInBytes / 1048576).toFixed(2)} MiB`;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$app.applyWorldDialogInstances();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
API.$on('FAVORITE', function (args) {
|
API.$on('FAVORITE', function (args) {
|
||||||
@@ -8595,15 +8619,36 @@ speechSynthesis.getVoices();
|
|||||||
D.id !== args.ref.id) {
|
D.id !== args.ref.id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
D.ref = args.ref;
|
var { ref } = args;
|
||||||
if (D.fileSize === 'Unknown') {
|
D.ref = ref;
|
||||||
var id = extractFileId(args.ref.assetUrl);
|
if (D.fileSize === 'Loading') {
|
||||||
if (id) {
|
var assetUrl = '';
|
||||||
D.fileSize = 'Loading';
|
for (var i = ref.unityPackages.length - 1; i > -1; i--) {
|
||||||
this.call(`file/${id}`).then((json) => {
|
var unityPackage = ref.unityPackages[i];
|
||||||
var ref = json.versions[json.versions.length - 1];
|
if ((unityPackage.platform === 'standalonewindows') &&
|
||||||
D.ref.created_at = ref.created_at;
|
(unityPackage.unitySortNumber <= 20180420000)) {
|
||||||
D.fileSize = `${(ref.file.sizeInBytes / 1048576).toFixed(2)} MiB`;
|
assetUrl = unityPackage.assetUrl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var fileId = extractFileId(assetUrl);
|
||||||
|
var fileVersion = extractFileVersion(assetUrl);
|
||||||
|
if (!fileId) {
|
||||||
|
var fileId = extractFileId(ref.assetUrl);
|
||||||
|
var fileVersion = extractFileVersion(ref.assetUrl);
|
||||||
|
}
|
||||||
|
if (fileId) {
|
||||||
|
API.getBundles(fileId).then((args) => {
|
||||||
|
var { versions } = args.json;
|
||||||
|
var ctx = '';
|
||||||
|
for (var i = versions.length - 1; i > -1; i--) {
|
||||||
|
var version = versions[i];
|
||||||
|
if (version.version == fileVersion) {
|
||||||
|
D.ref.created_at = version.created_at;
|
||||||
|
D.fileSize = `${(version.file.sizeInBytes / 1048576).toFixed(2)} MiB`;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8648,23 +8693,45 @@ speechSynthesis.getVoices();
|
|||||||
D.ref = ref;
|
D.ref = ref;
|
||||||
D.isFavorite = API.cachedFavoritesByObjectId.has(avatarId);
|
D.isFavorite = API.cachedFavoritesByObjectId.has(avatarId);
|
||||||
if (D.ref.authorId === API.currentUser.id) {
|
if (D.ref.authorId === API.currentUser.id) {
|
||||||
|
D.fileSize = 'Loading';
|
||||||
API.getAvatar({avatarId});
|
API.getAvatar({avatarId});
|
||||||
} else {
|
} else {
|
||||||
var id = extractFileId(D.ref.assetUrl);
|
var assetUrl = '';
|
||||||
var fileId = extractFileId(D.ref.imageUrl);
|
for (var i = ref.unityPackages.length - 1; i > -1; i--) {
|
||||||
if (id) {
|
var unityPackage = ref.unityPackages[i];
|
||||||
|
if ((unityPackage.platform === 'standalonewindows') &&
|
||||||
|
(unityPackage.unitySortNumber <= 20180420000)) {
|
||||||
|
assetUrl = unityPackage.assetUrl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var fileId = extractFileId(assetUrl);
|
||||||
|
var fileVersion = extractFileVersion(assetUrl);
|
||||||
|
if (!fileId) {
|
||||||
|
var fileId = extractFileId(ref.assetUrl);
|
||||||
|
var fileVersion = extractFileVersion(ref.assetUrl);
|
||||||
|
}
|
||||||
|
var imageId = extractFileId(ref.thumbnailImageUrl);
|
||||||
|
if (fileId) {
|
||||||
D.fileSize = 'Loading';
|
D.fileSize = 'Loading';
|
||||||
API.call(`file/${id}`).then((json) => {
|
API.getBundles(fileId).then((args) => {
|
||||||
var fileRef = json.versions[json.versions.length - 1];
|
var { versions } = args.json;
|
||||||
D.ref.created_at = fileRef.created_at;
|
var ctx = '';
|
||||||
D.fileSize = `${(fileRef.file.sizeInBytes / 1048576).toFixed(2)} MiB`;
|
for (var i = versions.length - 1; i > -1; i--) {
|
||||||
|
var version = versions[i];
|
||||||
|
if (version.version == fileVersion) {
|
||||||
|
D.ref.created_at = version.created_at;
|
||||||
|
D.fileSize = `${(version.file.sizeInBytes / 1048576).toFixed(2)} MiB`;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else if ((fileId) && (!D.ref.created_at)) {
|
} else if ((imageId) && (!D.ref.created_at)) {
|
||||||
if (API.cachedAvatarNames.has(fileId)) {
|
if (API.cachedAvatarNames.has(imageId)) {
|
||||||
var avatarInfo = API.cachedAvatarNames.get(fileId);
|
var avatarInfo = API.cachedAvatarNames.get(imageId);
|
||||||
D.ref.created_at = avatarInfo.fileCreatedAt;
|
D.ref.created_at = avatarInfo.fileCreatedAt;
|
||||||
} else {
|
} else {
|
||||||
API.getAvatarImages({fileId}).then((args) => {
|
API.getAvatarImages({fileId: imageId}).then((args) => {
|
||||||
var avatarInfo = this.storeAvatarImage(args);
|
var avatarInfo = this.storeAvatarImage(args);
|
||||||
D.ref.created_at = avatarInfo.fileCreatedAt;
|
D.ref.created_at = avatarInfo.fileCreatedAt;
|
||||||
});
|
});
|
||||||
@@ -11092,7 +11159,7 @@ speechSynthesis.getVoices();
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
API.getWorldBundles = async function (fileId) {
|
API.getBundles = async function (fileId) {
|
||||||
return this.call(`file/${fileId}`, {
|
return this.call(`file/${fileId}`, {
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
}).then((json) => {
|
}).then((json) => {
|
||||||
@@ -11115,14 +11182,45 @@ speechSynthesis.getVoices();
|
|||||||
var { ref, type } = this.downloadCurrent;
|
var { ref, type } = this.downloadCurrent;
|
||||||
this.downloadQueue.delete(ref.id);
|
this.downloadQueue.delete(ref.id);
|
||||||
this.downloadQueueTable.data = Array.from(this.downloadQueue.values());
|
this.downloadQueueTable.data = Array.from(this.downloadQueue.values());
|
||||||
|
var assetUrl = '';
|
||||||
var fileId = extractFileId(ref.assetUrl);
|
for (var i = ref.unityPackages.length - 1; i > -1; i--) {
|
||||||
var args = await API.getWorldBundles(fileId);
|
var unityPackage = ref.unityPackages[i];
|
||||||
|
if ((unityPackage.platform === 'standalonewindows') &&
|
||||||
|
(unityPackage.unitySortNumber <= 20180420000)) {
|
||||||
|
assetUrl = unityPackage.assetUrl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var fileId = extractFileId(assetUrl);
|
||||||
|
var fileVersion = extractFileVersion(assetUrl);
|
||||||
|
if (!fileId) {
|
||||||
|
this.downloadCurrent.status = 'Invalid asset url';
|
||||||
|
this.downloadHistoryTable.data.unshift(this.downloadCurrent);
|
||||||
|
this.downloadCurrent = {};
|
||||||
|
this.downloadInProgress = false;
|
||||||
|
this.downloadVRChatCache();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var args = await API.getBundles(fileId);
|
||||||
var { versions } = args.json;
|
var { versions } = args.json;
|
||||||
var version = versions[versions.length - 1];
|
var file = '';
|
||||||
var { url, md5, sizeInBytes } = version.file;
|
for (var i = versions.length - 1; i > -1; i--) {
|
||||||
|
var version = versions[i];
|
||||||
|
if (version.version == fileVersion) {
|
||||||
|
file = version.file;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!file) {
|
||||||
|
this.downloadCurrent.status = 'Missing asset version';
|
||||||
|
this.downloadHistoryTable.data.unshift(this.downloadCurrent);
|
||||||
|
this.downloadCurrent = {};
|
||||||
|
this.downloadInProgress = false;
|
||||||
|
this.downloadVRChatCache();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var { url, md5, sizeInBytes } = file;
|
||||||
var cacheDir = await this.getVRChatCacheDir();
|
var cacheDir = await this.getVRChatCacheDir();
|
||||||
console.log('start', ref.name, md5);
|
|
||||||
await AssetBundleCacher.DownloadCacheFile(cacheDir, url, ref.id, ref.version, sizeInBytes, md5, appVersion);
|
await AssetBundleCacher.DownloadCacheFile(cacheDir, url, ref.id, ref.version, sizeInBytes, md5, appVersion);
|
||||||
this.downloadVRChatCacheProgress();
|
this.downloadVRChatCacheProgress();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user