mirror of
https://github.com/HeyPuter/puter
synced 2024-11-15 06:15:47 +00:00
fix: handling of batch requests with zero files
This commit is contained in:
parent
80ea655d05
commit
c0063a871f
@ -28,6 +28,7 @@ const { TeePromise } = require("../../../util/promise");
|
|||||||
const { EWMA, MovingMode } = require("../../../util/opmath");
|
const { EWMA, MovingMode } = require("../../../util/opmath");
|
||||||
const { get_app } = require('../../../helpers');
|
const { get_app } = require('../../../helpers');
|
||||||
const { valid_file_size } = require("../../../util/validutil");
|
const { valid_file_size } = require("../../../util/validutil");
|
||||||
|
const { OnlyOnceFn } = require("../../../util/fnutil.js");
|
||||||
|
|
||||||
const commands = require('../../../filesystem/batch/commands.js').commands;
|
const commands = require('../../../filesystem/batch/commands.js').commands;
|
||||||
|
|
||||||
@ -137,7 +138,7 @@ module.exports = eggspress('/batch', {
|
|||||||
let total = 0;
|
let total = 0;
|
||||||
let total_tbd = true;
|
let total_tbd = true;
|
||||||
|
|
||||||
const on_first_file = () => {
|
const on_nonfile_data_end = OnlyOnceFn(() => {
|
||||||
if ( request_error ) {
|
if ( request_error ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -160,7 +161,7 @@ module.exports = eggspress('/batch', {
|
|||||||
pending_operations.splice(index, 1)[0];
|
pending_operations.splice(index, 1)[0];
|
||||||
response_promises.splice(index, 1);
|
response_promises.splice(index, 1);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------
|
//-------------------------------------------------------------
|
||||||
@ -228,7 +229,7 @@ module.exports = eggspress('/batch', {
|
|||||||
if ( batch_exe.total_tbd ) {
|
if ( batch_exe.total_tbd ) {
|
||||||
batch_exe.total_tbd = false;
|
batch_exe.total_tbd = false;
|
||||||
batch_widget.ic = pending_operations.length;
|
batch_widget.ic = pending_operations.length;
|
||||||
on_first_file();
|
on_nonfile_data_end();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( fileinfos.length == 0 ) {
|
if ( fileinfos.length == 0 ) {
|
||||||
@ -276,6 +277,7 @@ module.exports = eggspress('/batch', {
|
|||||||
// Awaiting responses
|
// Awaiting responses
|
||||||
//-------------------------------------------------------------
|
//-------------------------------------------------------------
|
||||||
await still_reading;
|
await still_reading;
|
||||||
|
on_nonfile_data_end();
|
||||||
|
|
||||||
if ( request_error ) {
|
if ( request_error ) {
|
||||||
return;
|
return;
|
||||||
|
@ -9,6 +9,16 @@ const UtilFn = fn => {
|
|||||||
return fn;
|
return fn;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const OnlyOnceFn = fn => {
|
||||||
|
let called = false;
|
||||||
|
return function onlyoncefn_call (...args) {
|
||||||
|
if ( called ) return;
|
||||||
|
called = true;
|
||||||
|
return fn(...args);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
UtilFn,
|
UtilFn,
|
||||||
|
OnlyOnceFn,
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user