mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 14:13:47 +02:00
Handle unzip failure
This commit is contained in:
parent
77676436a2
commit
e9dbb32277
4 changed files with 22 additions and 11 deletions
|
@ -1891,7 +1891,7 @@ void Application::initializeUi() {
|
|||
rootContext->setContextProperty("Entities", DependencyManager::get<EntityScriptingInterface>().data());
|
||||
_fileDownload = new FileScriptingInterface(engine);
|
||||
rootContext->setContextProperty("File", _fileDownload);
|
||||
connect(_fileDownload, &FileScriptingInterface::unzipSuccess, this, &Application::handleUnzip);
|
||||
connect(_fileDownload, &FileScriptingInterface::unzipResult, this, &Application::handleUnzip);
|
||||
rootContext->setContextProperty("MyAvatar", getMyAvatar().get());
|
||||
rootContext->setContextProperty("Messages", DependencyManager::get<MessagesClient>().data());
|
||||
rootContext->setContextProperty("Recording", DependencyManager::get<RecordingScriptingInterface>().data());
|
||||
|
@ -5649,6 +5649,12 @@ void Application::addAssetToWorldFromURLRequestFinished() {
|
|||
request->deleteLater();
|
||||
}
|
||||
|
||||
void Application::addAssetToWorldUnzipFailure(QString filePath) {
|
||||
QString filename = filePath.right(filePath.length() - filePath.lastIndexOf("/") - 1);
|
||||
qWarning(interfaceapp) << "Couldn't unzip file" << filePath;
|
||||
addAssetToWorldError(filename, "Couldn't unzip file " + filename + ".");
|
||||
}
|
||||
|
||||
void Application::addAssetToWorld(QString filePath) {
|
||||
// Automatically upload and add asset to world as an alternative manual process initiated by showAssetServerWidget().
|
||||
|
||||
|
@ -6020,11 +6026,15 @@ void Application::addAssetToWorldMessageClose() {
|
|||
}
|
||||
|
||||
|
||||
void Application::handleUnzip(QString filePath, bool autoAdd) {
|
||||
if (autoAdd && !filePath.isEmpty()) {
|
||||
addAssetToWorld(filePath);
|
||||
void Application::handleUnzip(QString zipFile, QString unzipFile, bool autoAdd) {
|
||||
if (autoAdd) {
|
||||
if (!unzipFile.isEmpty()) {
|
||||
addAssetToWorld(unzipFile);
|
||||
} else {
|
||||
addAssetToWorldUnzipFailure(zipFile);
|
||||
}
|
||||
} else {
|
||||
showAssetServerWidget(filePath);
|
||||
showAssetServerWidget(unzipFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -316,12 +316,13 @@ public slots:
|
|||
void addAssetToWorldFromURL(QString url);
|
||||
void addAssetToWorldFromURLRequestFinished();
|
||||
void addAssetToWorld(QString filePath);
|
||||
void addAssetToWorldUnzipFailure(QString filePath);
|
||||
void addAssetToWorldWithNewMapping(QString path, QString mapping, int copy);
|
||||
void addAssetToWorldUpload(QString path, QString mapping);
|
||||
void addAssetToWorldSetMapping(QString mapping, QString hash);
|
||||
void addAssetToWorldAddEntity(QString mapping);
|
||||
|
||||
void handleUnzip(QString filePath = "", bool autoAdd = false);
|
||||
void handleUnzip(QString sourceFile, QString destinationFile, bool autoAdd);
|
||||
|
||||
FileScriptingInterface* getFileDownloadInterface() { return _fileDownload; }
|
||||
|
||||
|
|
|
@ -44,13 +44,13 @@ void FileScriptingInterface::runUnzip(QString path, QUrl url, bool autoAdd) {
|
|||
}
|
||||
|
||||
QString file = unzipFile(path, tempDir);
|
||||
QString filename = QUrl::fromLocalFile(file).toString();
|
||||
if (file != "") {
|
||||
qDebug() << "Object file to upload: " + file;
|
||||
QUrl url = QUrl::fromLocalFile(file);
|
||||
emit unzipSuccess(url.toString(), autoAdd);
|
||||
qDebug() << "File to upload: " + filename;
|
||||
} else {
|
||||
qDebug() << "unzip failed";
|
||||
qDebug() << "Unzip failed";
|
||||
}
|
||||
emit unzipResult(path, filename, autoAdd);
|
||||
}
|
||||
|
||||
// fix to check that we are only referring to a temporary directory
|
||||
|
|
|
@ -28,7 +28,7 @@ public slots:
|
|||
QString getTempDir();
|
||||
|
||||
signals:
|
||||
void unzipSuccess(QString url, bool autoAdd);
|
||||
void unzipResult(QString zipFile, QString unzipFile, bool autoAdd);
|
||||
|
||||
private:
|
||||
bool isTempDir(QString tempDir);
|
||||
|
|
Loading…
Reference in a new issue