Skip to content

Commit d1511c5

Browse files
authored
Limit concurrent downloads & uploads (#2313)
1 parent c4c6d48 commit d1511c5

File tree

20 files changed

+412
-20
lines changed

20 files changed

+412
-20
lines changed

models/environment_constants.go

Lines changed: 70 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

models/session_response.go

Lines changed: 46 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

portal-ui/src/screens/Console/Buckets/ListBuckets/Objects/ListObjects/ListObjects.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ import {
9999

100100
import {
101101
makeid,
102+
removeTrace,
102103
storeCallForObjectWithID,
104+
storeFormDataWithID,
103105
} from "../../../../ObjectBrowser/transferManager";
104106
import {
105107
cancelObjectInList,
@@ -777,12 +779,15 @@ const ListObjects = () => {
777779
`${bucketName}-${object.name}-${new Date().getTime()}-${Math.random()}`
778780
);
779781

782+
const ID = makeid(8);
783+
780784
const downloadCall = download(
781785
bucketName,
782786
encodeURLString(object.name),
783787
object.version_id,
784788
object.size,
785789
null,
790+
ID,
786791
(progress) => {
787792
dispatch(
788793
updateProgress({
@@ -801,7 +806,6 @@ const ListObjects = () => {
801806
dispatch(cancelObjectInList(identityDownload));
802807
}
803808
);
804-
const ID = makeid(8);
805809
storeCallForObjectWithID(ID, downloadCall);
806810
dispatch(
807811
setNewObject({
@@ -818,8 +822,6 @@ const ListObjects = () => {
818822
errorMessage: "",
819823
})
820824
);
821-
822-
downloadCall.send();
823825
};
824826

825827
const openPath = (idElement: string) => {
@@ -865,6 +867,7 @@ const ListObjects = () => {
865867
const fileWebkitRelativePath = get(file, "webkitRelativePath", "");
866868

867869
let relativeFolderPath = folderPath;
870+
const ID = makeid(8);
868871

869872
// File was uploaded via drag & drop
870873
if (filePath !== "") {
@@ -924,6 +927,8 @@ const ListObjects = () => {
924927
if (xhr.status >= 200 && xhr.status < 300) {
925928
dispatch(completeObject(identity));
926929
resolve({ status: xhr.status });
930+
931+
removeTrace(ID);
927932
} else {
928933
// reject promise if there was a server error
929934
if (errorMessages[xhr.status]) {
@@ -936,13 +941,16 @@ const ListObjects = () => {
936941
errorMessage = "something went wrong";
937942
}
938943
}
944+
939945
dispatch(
940946
failObject({
941947
instanceID: identity,
942948
msg: errorMessage,
943949
})
944950
);
945951
reject({ status: xhr.status, message: errorMessage });
952+
953+
removeTrace(ID);
946954
}
947955
};
948956

@@ -990,7 +998,6 @@ const ListObjects = () => {
990998
const formData = new FormData();
991999
if (file.size !== undefined) {
9921000
formData.append(file.size.toString(), blobFile, fileName);
993-
const ID = makeid(8);
9941001
storeCallForObjectWithID(ID, xhr);
9951002
dispatch(
9961003
setNewObject({
@@ -1008,7 +1015,8 @@ const ListObjects = () => {
10081015
})
10091016
);
10101017

1011-
xhr.send(formData);
1018+
storeFormDataWithID(ID, formData);
1019+
storeCallForObjectWithID(ID, xhr);
10121020
}
10131021
});
10141022
};

portal-ui/src/screens/Console/Buckets/ListBuckets/Objects/ListObjects/ObjectDetailPanel.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,12 +302,15 @@ const ObjectDetailPanel = ({
302302
return;
303303
}
304304

305+
const ID = makeid(8);
306+
305307
const downloadCall = download(
306308
bucketName,
307309
internalPaths,
308310
object.version_id,
309311
parseInt(object.size || "0"),
310312
null,
313+
ID,
311314
(progress) => {
312315
dispatch(
313316
updateProgress({
@@ -326,7 +329,7 @@ const ObjectDetailPanel = ({
326329
dispatch(cancelObjectInList(identityDownload));
327330
}
328331
);
329-
const ID = makeid(8);
332+
330333
storeCallForObjectWithID(ID, downloadCall);
331334
dispatch(
332335
setNewObject({
@@ -343,8 +346,6 @@ const ObjectDetailPanel = ({
343346
errorMessage: "",
344347
})
345348
);
346-
347-
downloadCall.send();
348349
};
349350

350351
const closeDeleteModal = (closeAndReload: boolean) => {

portal-ui/src/screens/Console/Buckets/ListBuckets/Objects/ObjectDetails/VersionsNavigator.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,15 @@ const VersionsNavigator = ({
256256
`${bucketName}-${object.name}-${new Date().getTime()}-${Math.random()}`
257257
);
258258

259+
const ID = makeid(8);
260+
259261
const downloadCall = download(
260262
bucketName,
261263
internalPaths,
262264
object.version_id,
263265
parseInt(object.size || "0"),
264266
null,
267+
ID,
265268
(progress) => {
266269
dispatch(
267270
updateProgress({
@@ -280,7 +283,7 @@ const VersionsNavigator = ({
280283
dispatch(cancelObjectInList(identityDownload));
281284
}
282285
);
283-
const ID = makeid(8);
286+
284287
storeCallForObjectWithID(ID, downloadCall);
285288
dispatch(
286289
setNewObject({
@@ -297,8 +300,6 @@ const VersionsNavigator = ({
297300
errorMessage: "",
298301
})
299302
);
300-
301-
downloadCall.send();
302303
};
303304

304305
const onShareItem = (item: IFileInfo) => {

portal-ui/src/screens/Console/Buckets/ListBuckets/Objects/utils.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@
1717
import { BucketObjectItem } from "./ListObjects/types";
1818
import { IAllowResources } from "../../../types";
1919
import { encodeURLString } from "../../../../../common/utils";
20+
import { removeTrace } from "../../../ObjectBrowser/transferManager";
2021

2122
export const download = (
2223
bucketName: string,
2324
objectPath: string,
2425
versionID: any,
2526
fileSize: number,
2627
overrideFileName: string | null = null,
28+
id: string,
2729
progressCallback: (progress: number) => void,
2830
completeCallback: () => void,
2931
errorCallback: (msg: string) => void,
@@ -74,6 +76,8 @@ export const download = (
7476
completeCallback();
7577
}
7678

79+
removeTrace(id);
80+
7781
var link = document.createElement("a");
7882
link.href = window.URL.createObjectURL(req.response);
7983
link.download = filename;
@@ -104,7 +108,6 @@ export const download = (
104108
abortCallback();
105109
}
106110
};
107-
//req.send();
108111

109112
return req;
110113
};

portal-ui/src/screens/Console/Common/ObjectManager/ObjectHandled.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ const ObjectHandled = ({
170170
<button
171171
onClick={() => {
172172
if (!objectToDisplay.done) {
173-
console.log("//abort");
174173
const call = callForObjectID(objectToDisplay.ID);
175174
if (call) {
176175
call.abort();

0 commit comments

Comments
 (0)