()
| 1110 | |
| 1111 | // Goes through the queue and processes files if there aren't too many already. |
| 1112 | processQueue() { |
| 1113 | let { parallelUploads } = this.options; |
| 1114 | let processingLength = this.getUploadingFiles().length; |
| 1115 | let i = processingLength; |
| 1116 | |
| 1117 | // There are already at least as many files uploading than should be |
| 1118 | if (processingLength >= parallelUploads) { |
| 1119 | return; |
| 1120 | } |
| 1121 | |
| 1122 | let queuedFiles = this.getQueuedFiles(); |
| 1123 | |
| 1124 | if (!(queuedFiles.length > 0)) { |
| 1125 | return; |
| 1126 | } |
| 1127 | |
| 1128 | if (this.options.uploadMultiple) { |
| 1129 | // The files should be uploaded in one request |
| 1130 | return this.processFiles( |
| 1131 | queuedFiles.slice(0, parallelUploads - processingLength) |
| 1132 | ); |
| 1133 | } else { |
| 1134 | while (i < parallelUploads) { |
| 1135 | if (!queuedFiles.length) { |
| 1136 | return; |
| 1137 | } // Nothing left to process |
| 1138 | this.processFile(queuedFiles.shift()); |
| 1139 | i++; |
| 1140 | } |
| 1141 | } |
| 1142 | } |
| 1143 | |
| 1144 | // Wrapper for `processFiles` |
| 1145 | processFile(file) { |
no test coverage detected