Skip to content

Commit b64e5b4

Browse files
authored
[editor] Fix duplicate map meta entries resulting in editor suspending. (#543)
* [editor] Fix duplicate map meta entries resulting in editor suspending. * added debug messages
1 parent e558c84 commit b64e5b4

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

[editor]/editor_main/server/resourcehooks.lua

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,12 @@ function getResourceFiles ( resource, fileType )
101101
local file = xmlNodeGetAttribute ( node, "src" )
102102
local otherAttributes = xmlNodeGetAttributes ( node )
103103
otherAttributes.src = nil
104-
fileAttributes[file] = otherAttributes
105-
table.insert ( files, file )
104+
if fileAttributes[file] then
105+
outputDebugString("getResourceFiles: Found duplicate meta entry in '".. resource .."' (".. fileType .. " - ".. file .. ")")
106+
else
107+
fileAttributes[file] = otherAttributes
108+
table.insert ( files, file )
109+
end
106110
i = i + 1
107111
end
108112
xmlUnloadFile ( meta )
@@ -118,10 +122,15 @@ function copyResourceFiles ( fromResource, targetResource )
118122
local paths, attr = getResourceFiles(fromResource, fileType)
119123
if paths then
120124
for j,filePath in ipairs(paths) do
121-
fileCopy ( ":" .. getResourceName(fromResource) .. "/" .. filePath, ":" .. getResourceName(targetResource) .. "/" .. filePath, false )
122-
local data = attr[filePath]
123-
data.src = filePath
124-
table.insert ( targetPaths[fileType], data )
125+
local copyPath, copyTarget = ":" .. getResourceName(fromResource) .. "/" .. filePath, ":" .. getResourceName(targetResource) .. "/" .. filePath
126+
if fileExists(copyTarget) then
127+
outputDebugString("copyResourceFiles: File '".. copyTarget .."' has duplicate meta entries, cannot overwrite.")
128+
else
129+
fileCopy ( copyPath, copyTarget, false )
130+
local data = attr[filePath]
131+
data.src = filePath
132+
table.insert ( targetPaths[fileType], data )
133+
end
125134
end
126135
else
127136
outputDebugString("copyResourceFiles: getResourceFiles returned "..tostring(paths).." and "..tostring(attr).." for "..tostring(fromResource).." and "..tostring(fileType))

0 commit comments

Comments
 (0)