MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / updateProgress

Function updateProgress

runtime/src/js/downloader.js:42–65  ·  view source on GitHub ↗
(callerWindow)

Source from the content-addressed store, hash-verified

40const downloadQueue = {};
41
42function updateProgress(callerWindow) {
43 let count = Object.keys(downloadQueue).length;
44 if (count === 0) {
45 clearBadge();
46 clearProgress.call(callerWindow);
47 return;
48 }
49 setBadge(Object.keys(downloadQueue).length);
50 let progress;
51 if(Object.values(downloadQueue).some((item) => item.total === null)) {
52 // If any of the items in the queue does not have a total, we cannot calculate progress
53 // so we return 2 to indicate that the progress is indeterminate.
54 progress = 2;
55 } else {
56 const total = Object.values(downloadQueue).reduce((acc, item) => {
57 if (item.total) {
58 return acc + item.currentLoaded / item.total;
59 }
60 return acc + item.currentLoaded;
61 }, 0);
62 progress = total / Object.keys(downloadQueue).length;
63 }
64 setProgress.call(callerWindow, progress);
65}
66
67async function fileDownloadPath(callerWindow, options, prompt=true) {
68 let filePath = path.join(app.getPath('downloads'), options.defaultPath);

Callers 1

setupDownloaderFunction · 0.85

Calls 2

clearBadgeFunction · 0.90
setBadgeFunction · 0.90

Tested by

no test coverage detected