mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 10:37:35 +02:00
Handle duplicate Clara download asset names
This commit is contained in:
parent
3ca2c19075
commit
cee8b66ce9
2 changed files with 27 additions and 1 deletions
|
@ -5344,7 +5344,32 @@ void Application::addAssetToWorld(QString filePath) {
|
||||||
QString path = QUrl(filePath).toLocalFile();
|
QString path = QUrl(filePath).toLocalFile();
|
||||||
QString mapping = path.right(path.length() - path.lastIndexOf("/"));
|
QString mapping = path.right(path.length() - path.lastIndexOf("/"));
|
||||||
|
|
||||||
addAssetToWorldUpload(path, mapping);
|
addAssetToWorldWithNewMapping(path, mapping, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Application::addAssetToWorldWithNewMapping(QString path, QString mapping, int copy) {
|
||||||
|
auto request = DependencyManager::get<AssetClient>()->createGetMappingRequest(mapping);
|
||||||
|
QObject::connect(request, &GetMappingRequest::finished, this, [=](GetMappingRequest* request) mutable {
|
||||||
|
const int MAX_COPY_COUNT = 100; // Limit number of duplicate assets; recursion guard.
|
||||||
|
if (request->getError() == GetMappingRequest::NotFound) {
|
||||||
|
addAssetToWorldUpload(path, mapping);
|
||||||
|
} else if (copy < MAX_COPY_COUNT - 1) {
|
||||||
|
if (copy > 0) {
|
||||||
|
mapping = mapping.remove(mapping.lastIndexOf("-"), QString::number(copy).length() + 1);
|
||||||
|
}
|
||||||
|
copy++;
|
||||||
|
mapping = mapping.insert(mapping.lastIndexOf("."), "-" + QString::number(copy));
|
||||||
|
addAssetToWorldWithNewMapping(path, mapping, copy);
|
||||||
|
} else {
|
||||||
|
QString errorInfo = "Too many copies of asset name: "
|
||||||
|
+ mapping.left(mapping.length() - QString::number(copy).length() - 1);
|
||||||
|
qCDebug(interfaceapp) << "Error downloading asset: " + errorInfo;
|
||||||
|
OffscreenUi::warning("Error Downloading Asset", errorInfo);
|
||||||
|
}
|
||||||
|
request->deleteLater();
|
||||||
|
});
|
||||||
|
|
||||||
|
request->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::addAssetToWorldUpload(QString path, QString mapping) {
|
void Application::addAssetToWorldUpload(QString path, QString mapping) {
|
||||||
|
|
|
@ -307,6 +307,7 @@ public slots:
|
||||||
void toggleRunningScriptsWidget() const;
|
void toggleRunningScriptsWidget() const;
|
||||||
Q_INVOKABLE void showAssetServerWidget(QString filePath = "");
|
Q_INVOKABLE void showAssetServerWidget(QString filePath = "");
|
||||||
void addAssetToWorld(QString filePath);
|
void addAssetToWorld(QString filePath);
|
||||||
|
void addAssetToWorldWithNewMapping(QString path, QString mapping, int copy);
|
||||||
void addAssetToWorldUpload(QString path, QString mapping);
|
void addAssetToWorldUpload(QString path, QString mapping);
|
||||||
void addAssetToWorldSetMapping(QString mapping, QString hash);
|
void addAssetToWorldSetMapping(QString mapping, QString hash);
|
||||||
void addAssetToWorldAddEntity(QString mapping);
|
void addAssetToWorldAddEntity(QString mapping);
|
||||||
|
|
Loading…
Reference in a new issue