Skip to content

Commit 67d5e06

Browse files
committed
apploader - install-app-from-files - add count of data files
1 parent e08cff6 commit 67d5e06

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

install_from_files.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,16 +129,28 @@ function installFromFiles() {
129129
});
130130
}
131131

132-
// Determine number of files that will actually be transferred
133-
// This counts only files from storage[] that we found in the selected files
134-
var transferCount = app.storage.filter(storageEntry => {
132+
// Determine number of storage files that will actually be transferred
133+
var storageTransferCount = app.storage.filter(storageEntry => {
135134
var url = storageEntry.url || storageEntry.name;
136135
return fileMap[url];
137136
}).length;
138137

139-
// Confirm with user, listing transfer count instead of raw selected file count
138+
// Determine number of data files expected to be transferred (url/content present, not wildcard)
139+
var dataTransferCount = 0;
140+
if (app.data && Array.isArray(app.data)) {
141+
app.data.forEach(dataEntry => {
142+
if (dataEntry.wildcard) return; // pattern only
143+
if (!dataEntry.url && !dataEntry.content) return; // no source specified
144+
var url = dataEntry.url || dataEntry.name;
145+
if (dataEntry.content || fileMap[url]) dataTransferCount++;
146+
});
147+
}
148+
149+
// Build breakdown string (omit data if zero)
150+
var breakdown = `${storageTransferCount} storage file(s)` + (dataTransferCount>0 ? ` and ${dataTransferCount} data file(s)` : "");
151+
140152
showPrompt("Install App from Files",
141-
`Install app "${app.name}" (${app.id}) version ${app.version}?\n\nWill transfer ${transferCount} file(s) from metadata.\n\nThis will delete the existing version if installed.`
153+
`Install app "${app.name}" (${app.id}) version ${app.version}?\n\nWill transfer ${breakdown} from metadata.\n\nThis will delete the existing version if installed.`
142154
).then(() => {
143155
Progress.show({title:`Reading files...`});
144156

0 commit comments

Comments
 (0)