pangea-server 3.3.79 → 3.3.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -95,14 +95,19 @@ async function setFilesUrls(data) {
|
|
|
95
95
|
});
|
|
96
96
|
arrayTargets.forEach(({ node, key }) => {
|
|
97
97
|
const arr = node[key];
|
|
98
|
+
if (!Array.isArray(arr))
|
|
99
|
+
return;
|
|
98
100
|
arr.forEach((v) => {
|
|
99
101
|
if (typeof v === 'string' && v.length)
|
|
100
102
|
filesSet.add(v);
|
|
101
103
|
});
|
|
102
104
|
});
|
|
103
105
|
const files = Array.from(filesSet);
|
|
104
|
-
if (!files.length)
|
|
106
|
+
if (!files.length) {
|
|
107
|
+
arrayTargets.forEach(({ node, key }) => (node[`${key}Urls`] = []));
|
|
108
|
+
singleTargets.forEach(({ node, key }) => (node[`${key}Url`] = null));
|
|
105
109
|
return;
|
|
110
|
+
}
|
|
106
111
|
const urls = await Promise.all(files.map((file) => helpers_1.FileStorage.GenerateDownloadUrl(file)));
|
|
107
112
|
const map = new Map();
|
|
108
113
|
files.forEach((file, i) => map.set(file, urls[i]));
|
|
@@ -112,6 +117,6 @@ async function setFilesUrls(data) {
|
|
|
112
117
|
});
|
|
113
118
|
arrayTargets.forEach(({ node, key }) => {
|
|
114
119
|
const arr = node[key];
|
|
115
|
-
node[`${key}Urls`] = Array.isArray(arr) ? arr.map((v) => (v ? map.get(v)
|
|
120
|
+
node[`${key}Urls`] = Array.isArray(arr) ? arr.map((v) => (v && map.has(v) ? map.get(v) : null)) : [];
|
|
116
121
|
});
|
|
117
122
|
}
|