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