fix checking file early
This commit is contained in:
parent
e4a0028f5d
commit
12ccce3016
@ -141,11 +141,11 @@ async function upload(
|
||||
let size = 0;
|
||||
while (!state.done) {
|
||||
const buf = state.value;
|
||||
ws.send(buf);
|
||||
|
||||
if (canceller.cancelled) {
|
||||
ws.close(4000, 'upload cancelled');
|
||||
throw new Error(0);
|
||||
}
|
||||
ws.send(buf);
|
||||
|
||||
onprogress([Math.min(streamInfo.fileSize, size), streamInfo.fileSize]);
|
||||
size += streamInfo.recordSize;
|
||||
@ -174,7 +174,6 @@ export async function uploadWs(
|
||||
|
||||
return {
|
||||
cancel: function() {
|
||||
ws.close(4000, 'upload cancelled');
|
||||
canceller.cancelled = true;
|
||||
},
|
||||
result: upload(
|
||||
|
@ -52,7 +52,7 @@ export default function(state, emitter) {
|
||||
checkFiles();
|
||||
});
|
||||
|
||||
emitter.on('navigate', checkFiles);
|
||||
//emitter.on('navigate', checkFiles);
|
||||
|
||||
emitter.on('render', () => {
|
||||
lastRender = Date.now();
|
||||
|
@ -62,10 +62,6 @@ module.exports = function(app) {
|
||||
app.post(`/api/params/:id${ID_REGEX}`, owner, require('./params'));
|
||||
app.post(`/api/info/:id${ID_REGEX}`, owner, require('./info'));
|
||||
|
||||
if (!IS_DEV) {
|
||||
app.ws('/api/ws', require('./ws'));
|
||||
}
|
||||
|
||||
app.get('/__version__', function(req, res) {
|
||||
res.sendFile(require.resolve('../../dist/version.json'));
|
||||
});
|
||||
|
@ -44,13 +44,13 @@ module.exports = async function(ws, req) {
|
||||
nonce: crypto.randomBytes(16).toString('base64')
|
||||
};
|
||||
|
||||
const protocol = config.env === 'production' ? 'https' : req.protocol;
|
||||
const url = `${protocol}://${req.get('host')}/download/${newId}/`;
|
||||
|
||||
const limiter = new Limiter(config.max_file_size);
|
||||
fileStream = wsStream(ws, { binary: true }).pipe(limiter);
|
||||
storage.set(newId, fileStream, meta);
|
||||
|
||||
const protocol = config.env === 'production' ? 'https' : req.protocol;
|
||||
const url = `${protocol}://${req.get('host')}/download/${newId}/`;
|
||||
|
||||
ws.send(
|
||||
JSON.stringify({
|
||||
url,
|
||||
|
Loading…
Reference in New Issue
Block a user