Fix image upload with the same name in onlyoffice

pull/1/head
yflory 4 years ago
parent bdbfbaa109
commit f7e777d5a6

@ -1457,6 +1457,25 @@ define([
// Add image to the list // Add image to the list
var mediasSources = getMediasSources(); var mediasSources = getMediasSources();
// Check if name already exists
var getUniqueName = function (name, mediasSources) {
var get = function () {
var s = name.split('.');
if (s.length > 1) {
s[s.length - 2] = s[s.length - 2] + '-' + Util.uid();
name = s.join('.');
} else {
name += '-'+ Util.uid();
}
};
while (mediasSources[name]) { get(); }
return name;
};
if (mediasSources[name]) {
name = getUniqueName(name, mediasSources);
data.name = name;
}
mediasSources[name] = data; mediasSources[name] = data;
APP.onLocal(); APP.onLocal();

Loading…
Cancel
Save