mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 16:00:01 +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) {
|
||||
console.log("Renaming " + oldPath + " to " + newPath);
|
||||
|
||||
if (newPath[0] != "/") {
|
||||
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) {
|
||||
if (err) {
|
||||
console.log("Error renaming: ", oldPath, "=>", newPath, " - error ", err);
|
||||
|
|
|
@ -174,6 +174,19 @@ void AssetMappingsScriptingInterface::renameMapping(QString oldPath, QString new
|
|||
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) :
|
||||
name(name),
|
||||
|
|
|
@ -35,7 +35,8 @@
|
|||
public:
|
||||
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:
|
||||
void errorGettingMappings(int error);
|
||||
|
@ -55,7 +56,8 @@ public:
|
|||
Q_INVOKABLE AssetMappingModel* getAssetMappingModel() { return &_assetMappingModel; }
|
||||
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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue