Web: Files: Upload: moved chunkUploadCount to SettingsStore

This commit is contained in:
Nikita Gopienko 2024-01-23 16:44:34 +03:00
parent fb8712a8c8
commit 772ec79d99
3 changed files with 9 additions and 9 deletions

View File

@ -36,6 +36,7 @@ class SettingsStore {
keepNewFileName = null; keepNewFileName = null;
thumbnails1280x720 = window.DocSpaceConfig?.thumbnails1280x720 || false; thumbnails1280x720 = window.DocSpaceConfig?.thumbnails1280x720 || false;
chunkUploadSize = 1024 * 1023; // 1024 * 1023; //~0.999mb chunkUploadSize = 1024 * 1023; // 1024 * 1023; //~0.999mb
chunkUploadCount = 5;
settingsIsLoaded = false; settingsIsLoaded = false;

View File

@ -31,9 +31,6 @@ import {
getCategoryUrl, getCategoryUrl,
} from "SRC_DIR/helpers/utils"; } from "SRC_DIR/helpers/utils";
const UPLOAD_LIMIT_AT_ONCE = 5;
const ASYNC_UPLOAD_LIMIT_AT_ONCE = 5;
class UploadDataStore { class UploadDataStore {
authStore; authStore;
treeFoldersStore; treeFoldersStore;
@ -1129,6 +1126,7 @@ class UploadDataStore {
operationId, operationId,
toFolderId toFolderId
) => { ) => {
const { chunkUploadCount: asyncChunkUploadCount } = this.settingsStore;
const length = requestsDataArray.length; const length = requestsDataArray.length;
const isThirdPartyFolder = typeof toFolderId === "string"; const isThirdPartyFolder = typeof toFolderId === "string";
@ -1160,9 +1158,7 @@ class UploadDataStore {
const promise = new Promise((resolve, reject) => { const promise = new Promise((resolve, reject) => {
let i = let i =
length <= ASYNC_UPLOAD_LIMIT_AT_ONCE length <= asyncChunkUploadCount ? length : asyncChunkUploadCount;
? length
: ASYNC_UPLOAD_LIMIT_AT_ONCE;
while (i !== 0) { while (i !== 0) {
this.asyncUpload( this.asyncUpload(
t, t,
@ -1226,13 +1222,15 @@ class UploadDataStore {
// console.log("IS PARALLEL"); // console.log("IS PARALLEL");
const notUploadedFiles = this.files.filter((f) => !f.inAction); const notUploadedFiles = this.files.filter((f) => !f.inAction);
const { chunkUploadCount } = this.settingsStore;
const countFiles = const countFiles =
notUploadedFiles.length >= UPLOAD_LIMIT_AT_ONCE notUploadedFiles.length >= chunkUploadCount
? UPLOAD_LIMIT_AT_ONCE ? chunkUploadCount
: notUploadedFiles.length; : notUploadedFiles.length;
for (let i = 0; i < countFiles; i++) { for (let i = 0; i < countFiles; i++) {
if (this.currentUploadNumber <= UPLOAD_LIMIT_AT_ONCE) { if (this.currentUploadNumber <= chunkUploadCount) {
const fileIndex = this.files.findIndex( const fileIndex = this.files.findIndex(
(f) => f.uniqueId === notUploadedFiles[i].uniqueId (f) => f.uniqueId === notUploadedFiles[i].uniqueId
); );

View File

@ -180,6 +180,7 @@ export type TFilesSettings = {
}; };
canSearchByContent: boolean; canSearchByContent: boolean;
chunkUploadSize: number; chunkUploadSize: number;
chunkUploadCount: number;
confirmDelete: boolean; confirmDelete: boolean;
convertNotify: boolean; convertNotify: boolean;
defaultOrder: { is_asc: boolean; property: 1 }; defaultOrder: { is_asc: boolean; property: 1 };