mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 22:36:57 +02:00
Don't allow folder overwrite
This commit is contained in:
parent
2fb478ff3c
commit
35f5ebb938
3 changed files with 23 additions and 4 deletions
|
@ -72,12 +72,16 @@ Window {
|
||||||
|
|
||||||
}
|
}
|
||||||
function doRenameFile(oldPath, newPath) {
|
function doRenameFile(oldPath, newPath) {
|
||||||
console.log("Renaming " + oldPath + " to " + newPath);
|
|
||||||
|
|
||||||
if (newPath[0] != "/") {
|
if (newPath[0] != "/") {
|
||||||
newPath = "/" + newPath;
|
newPath = "/" + newPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Assets.isKnownFolder(newPath)) {
|
||||||
|
box = errorMessageBox("Cannot override existing directory.");
|
||||||
|
box.selected.connect(reload);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("Renaming " + oldPath + " to " + newPath);
|
||||||
Assets.renameMapping(oldPath, newPath, function(err) {
|
Assets.renameMapping(oldPath, newPath, function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log("Error renaming: ", oldPath, "=>", newPath, " - error ", err);
|
console.log("Error renaming: ", oldPath, "=>", newPath, " - error ", err);
|
||||||
|
|
|
@ -174,6 +174,19 @@ void AssetMappingsScriptingInterface::renameMapping(QString oldPath, QString new
|
||||||
request->start();
|
request->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AssetMappingModel::isKnownFolder(QString path) const {
|
||||||
|
if (!path.endsWith("/")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto existingPaths = _pathToItemMap.keys();
|
||||||
|
for (auto& entry : existingPaths) {
|
||||||
|
if (entry.startsWith(path)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
AssetMappingItem::AssetMappingItem(const QString& name, const QString& fullPath, bool isFolder) :
|
AssetMappingItem::AssetMappingItem(const QString& name, const QString& fullPath, bool isFolder) :
|
||||||
name(name),
|
name(name),
|
||||||
|
|
|
@ -35,7 +35,8 @@
|
||||||
public:
|
public:
|
||||||
Q_INVOKABLE void refresh();
|
Q_INVOKABLE void refresh();
|
||||||
|
|
||||||
bool isKnownMapping(QString path) const { return _pathToItemMap.contains(path); };
|
bool isKnownMapping(QString path) const { return _pathToItemMap.contains(path); }
|
||||||
|
bool isKnownFolder(QString path) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void errorGettingMappings(int error);
|
void errorGettingMappings(int error);
|
||||||
|
@ -55,7 +56,8 @@ public:
|
||||||
Q_INVOKABLE AssetMappingModel* getAssetMappingModel() { return &_assetMappingModel; }
|
Q_INVOKABLE AssetMappingModel* getAssetMappingModel() { return &_assetMappingModel; }
|
||||||
Q_INVOKABLE QAbstractProxyModel* getProxyModel() { return &_proxyModel; }
|
Q_INVOKABLE QAbstractProxyModel* getProxyModel() { return &_proxyModel; }
|
||||||
|
|
||||||
Q_INVOKABLE bool isKnownMapping(QString path) const { return _assetMappingModel.isKnownMapping(path); };
|
Q_INVOKABLE bool isKnownMapping(QString path) const { return _assetMappingModel.isKnownMapping(path); }
|
||||||
|
Q_INVOKABLE bool isKnownFolder(QString path) const { return _assetMappingModel.isKnownFolder(path); }
|
||||||
|
|
||||||
Q_INVOKABLE QString getErrorString(int errorCode) const;
|
Q_INVOKABLE QString getErrorString(int errorCode) const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue