mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 16:49:58 +02:00
Fix Clara download failing if move mouse after initiating download
This commit is contained in:
parent
e79f6b1203
commit
b672b7e177
2 changed files with 7 additions and 5 deletions
|
@ -96,7 +96,7 @@ Rectangle {
|
|||
property string replaceFBXDownload: 'var element = $("a[data-extension=\'fbx\']:first");
|
||||
element.unbind("click");
|
||||
element.bind("click", function(event) {
|
||||
console.log("Initiate Clara.io FBX file download");
|
||||
console.log("Initiate Clara.io FBX file download for {uuid}");
|
||||
window.open("https://clara.io/api/scenes/{uuid}/export/fbx?fbxVersion=7.4&fbxEmbedTextures=true¢erScene=true&alignSceneGound=true");
|
||||
return false;
|
||||
});'
|
||||
|
@ -105,7 +105,7 @@ Rectangle {
|
|||
desktop.currentUrl = hoveredUrl;
|
||||
|
||||
if (desktop.isClaraFBXZipDownload(desktop.currentUrl)) {
|
||||
var doReplaceFBXDownload = replaceFBXDownload.replace("{uuid}", desktop.currentUrl.slice(desktop.currentUrl.lastIndexOf("/") + 1, -1));
|
||||
var doReplaceFBXDownload = replaceFBXDownload.replace(/{uuid}/g, desktop.currentUrl.slice(desktop.currentUrl.lastIndexOf("/") + 1, -1));
|
||||
runJavaScript(doReplaceFBXDownload);
|
||||
}
|
||||
|
||||
|
|
|
@ -100,6 +100,7 @@ OriginalDesktop.Desktop {
|
|||
// Accept a download through the webview
|
||||
property bool webViewProfileSetup: false
|
||||
property string currentUrl: ""
|
||||
property string downloadUrl: ""
|
||||
property string adaptedPath: ""
|
||||
property string tempDir: ""
|
||||
property bool autoAdd: false
|
||||
|
@ -111,16 +112,17 @@ OriginalDesktop.Desktop {
|
|||
|
||||
function initWebviewProfileHandlers(profile) {
|
||||
console.log("The webview url in desktop is: " + currentUrl);
|
||||
downloadUrl = currentUrl;
|
||||
if (webViewProfileSetup) return;
|
||||
webViewProfileSetup = true;
|
||||
|
||||
profile.downloadRequested.connect(function(download){
|
||||
console.log("Download start: " + download.state);
|
||||
adaptedPath = File.convertUrlToPath(currentUrl);
|
||||
adaptedPath = File.convertUrlToPath(downloadUrl);
|
||||
tempDir = File.getTempDir();
|
||||
console.log("Temp dir created: " + tempDir);
|
||||
download.path = tempDir + "/" + adaptedPath;
|
||||
if (isClaraFBXZipDownload(currentUrl)) {
|
||||
if (isClaraFBXZipDownload(downloadUrl)) {
|
||||
download.path += "fbx.zip";
|
||||
}
|
||||
console.log("Path where object should download: " + download.path);
|
||||
|
@ -133,7 +135,7 @@ OriginalDesktop.Desktop {
|
|||
|
||||
profile.downloadFinished.connect(function(download){
|
||||
if (download.state === WebEngineDownloadItem.DownloadCompleted) {
|
||||
File.runUnzip(download.path, currentUrl, autoAdd);
|
||||
File.runUnzip(download.path, downloadUrl, autoAdd);
|
||||
} else {
|
||||
console.log("The download was corrupted, state: " + download.state);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue